1

웹 사이트의 페이지 구독을 구축 중입니다. 따라서 양식을 통해 구독자가되고 Dynamics 365 Online의 마케팅 목록에 추가됩니다.Dynamics 365 웹 API 이메일 보내기

웹 사이트의 예약 된 작업에서 마케팅 담당자의 연락처를 요청합니다.

그런 다음이 속성과 해당 페이지로 연결되는 링크로 새 페이지가 만들어 졌음을 이메일로 보내야합니다.

그래서 Dynamics 365 Online에 대한 책임을 맡고 싶습니다.

그래서 웹 API와 다음 작업을 사용하고 있습니다. SendEmailFromTemplate 이 작업을 사용할 수 있는지 또는 사용자 지정 작업을 만들어야하는지 잘 모르겠습니다.

페이지, 제목 및 텍스트의 URL과 같은 데이터를 전달해야합니다. 또는 하나의 문자열 -이 모든 것을 포함하는 전자 메일 메시지 본문.

그래서 CRM에서 전자 메일 템플릿을 만들었고 코드에서 찾은 것처럼 semse했습니다.

내가 생각하는 작업입니다 난 후 해요 : https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.sendemailfromtemplaterequest.aspx?cs-save-lang=1&amp

하지만 난 웹 API와 함께 갈거야 : 내가 SOAP 서비스에서 문서를 선택하면 https://msdn.microsoft.com/en-us/library/mt607523.aspx

실제로 사례가있다 .

그래서 나는이 시도 :

dynamic regarding = new ExpandoObject(); 
var oppIndexer = regarding as IDictionary<string, Object>; 
oppIndexer["contactid"] = contact.ContactId; //contact that will recive the 
email. 
oppIndexer["@odata.type"] = "Microsoft.Dynamics.CRM.contact"; 

dynamic target = new ExpandoObject(); 
var targetIndexer = target as IDictionary<string, Object>; 
targetIndexer["torecipients"] = "[email protected]"; 
targetIndexer["sender"] = "[email protected]"; 
targetIndexer["inreplyto"] = "[email protected]"; 
targetIndexer["subject"] = "This is the subject"; 
targetIndexer["description"] = "This should be the body of the email"; 
targetIndexer["directioncode"] = true; //outgoing 
targetIndexer["@odata.type"] = "Microsoft.Dynamics.CRM.email"; 

dynamic sendEmailFromTemplate = new ExpandoObject(); 
sendEmailFromTemplate.TemplateId = Guid.Parse("my-email-template-guid-inserted-here"); 
sendEmailFromTemplate.Regarding = regarding; 
sendEmailFromTemplate.Target = target; 

api.ExecuteAction("SendEmailFromTemplate", sendEmailFromTemplate); 

을하지만 난 예외를 얻을 : 내가 그것을 게시 할 때 "이 전송되기 전에 전자 메일이 하나 이상의받는 사람이 있어야합니다."

무슨 문제 일 수 있습니까? 대상과 관련에 대한 형식 유형 "crmbaseentity"이어야한다는 https://msdn.microsoft.com/en-us/library/mt607523.aspx

그냥 선언

나는의 문서 생각합니다. 기본 클래스 ...

누구든지이 문제를 일으킬 수 있습니다. 분야 "torecipients는"사람이 읽을 수에 대한 https://msdn.microsoft.com/en-us/library/mt608007.aspx

: "이메일 주소가 수신자에 해당하는 표시"

은 이메일 엔티티입니다. 그래서 내가 사용해야 할 분야인지 모르겠습니다. 텍스트가 "받는 사람", "메시지를받는 구분 기호"라면이 필드를 사용해야한다는 것이 더 확실합니다.

업데이트 :

{ 
"email_activity_parties": [ 
    { "[email protected]": "/systemusers(852a441c-b544-e611-80e3-c4346bc5e750)", "participationtypemask": 1 }, 
    { "[email protected]": "/systemusers(852a441c-b544-e611-80e3-c4346bc5e750)", "participationtypemask": 2 } 
    ], 
"description": "description lorem ipsum", 
"subject": "rubrik", 
"[email protected]": "/opportunities(e9e6eb64-9c4c-e611-80e4-c4346bc58294)" 
} 

난이 너무 내 요구에 맞는 변경하려면 것 경우 : 좋아요, 그래서 이것은 당신이 게시 된 것입니다. 나는 메신저가 기회를 이용하려고하지 않는다고 생각한다. 아니면 내가해야합니까? SendEmailFromTemplate 동작에는 세 가지 매개 변수가 있습니다. https://msdn.microsoft.com/en-us/library/mt607523.aspx TemplateId, Regarding 및 Target.나는 약간 아래 (테스트되지 않은)이 코드

{ 
"TemplateId": "id-for-email-template", 
"Regarding": [ { "[email protected]": "/contacts(contact-guid-X)" } ], 
"Target": { 
    "email_activity_parties": [ 
     { "[email protected]": "/systemusers(systemuser-guid-Y)", "participationtypemask": 1 }, //1 is "sender" 
     { "[email protected]": "/contacts(contact-guid-X)", "participationtypemask": 2 } // 2 is "to" 
     ], 
    "description": "description lorem ipsum", 
    "subject": "rubrik", 
    "[email protected]": "/contacts(contact-guid-X)" 
    } 
} 

나는 이런 식으로 뭔가를하려고합니다 ..

+0

내가 생각하는 @ odata.type을 설정해야합니다 ... –

답변

0

리스팅 활동이며, 모든 활동은 활동 포인터 + 활동 파티로 분할됩니다 변경. What you have to doregardingobject과 동일한 연락처를 넣고 toParty에도 입력하십시오.

//create activityparty 
Entity Fromparty = new Entity("activityparty"); 
Entity Toparty = new Entity("activityparty"); 

//To set to Contact 
Toparty["partyid"]= new EntityReference("contact", _ contactid)); 

//From set to User 
Fromparty["partyid"]= new EntityReference("systemuser", _From)); 

//create email Object and set attributes 
Entity email = new Entity("email"); 

email["from"] = new Entity[] { Fromparty }; 
email["to"] = new Entity[] { Toparty }; 
email["directioncode"] = true; 

//setting the Regarding as Contact 
email["regardingobjectid"] = new EntityReference("contact", _contactid); 

Ignoretorecipients 필드, to 만 사용합니다.

오류 The e-mail must have at least one recipient before it can be sent이 사라집니다.

업데이트 :

웹 API 측면에서 탐색 속성을 사용해야합니다.

//Create email 
var email = new JObject(
      new JProperty("email_activity_parties", 
      new JArray(
        new JObject(
          new JProperty("[email protected]", "/systemusers (<guid>)"), 
      new JProperty("participationtypemask", 1)), 
        new JObject(
          new JProperty("[email protected]", "/systemusers(<guid>)"), 
        new JProperty("participationtypemask", 2)))), 
        new JProperty("description", txtEmail.Text.Replace("\r\n","<br>")), 
        new JProperty("subject", "Test Subject"), 
        new JProperty("[email protected]", "/opportunities(<guid>)")); 
+0

이 예제는 많이 보았지만 웹 API 예제는 없습니다. JSON 게시판은 어떻게 생겼을까요? –

+0

좋아, 나는 내 메인 포스트에서 업데이트를했다. 나는 두 가지를 바꾸어야한다고 생각한다. 약간의 테스트를 할 것입니다. –