使用CRM 4.0 SDK一次向多个联系人发送电子邮件

发布于 2024-10-24 16:35:12 字数 1325 浏览 1 评论 0原文

是否可以发送“收件人”字段中指定的多个电子邮件地址的电子邮件?我让它适用于单个收件人,但无法弄清楚如何发送给多个收件人,这是我当前用于向单个用户发送电子邮件的代码:

 public static void sendCRMNotification(string userGuid, string emailSubject, string emailBody, string recipientType) 

{  

//Set up CRM service
crmService crmservice = GetCrmService();

// Create a FROM activity party for the email.
activityparty fromParty = new activityparty();
fromParty.partyid = new Lookup();
fromParty.partyid.type = EntityName.systemuser.ToString();
fromParty.partyid.Value = new Guid(/*guid of sending user*/);

//Create a TO activity party for email
activityparty toParty = new activityparty();
toParty.partyid = new Lookup();
toParty.partyid.type = EntityName.contact.ToString();
toParty.partyid.Value = new Guid(userGuid);

//Create a new email
email emailInstance = new email();

//set email parameters
emailInstance.from = new activityparty[] { fromParty };
emailInstance.to = new activityparty[] { toParty };
emailInstance.subject = emailSubject;
emailInstance.description = emailBody;

//Create a GUId for the email
Guid emailId = crmservice.Create(emailInstance);

//Create a SendEmailRequest
SendEmailRequest request = new SendEmailRequest();
request.EmailId = emailId;
request.IssueSend = true;
request.TrackingToken = "";

 //Execute request
crmservice.Execute(request);
}

Is it possible to send out an email with multiple email addresses specified in the "to" field? I have it working for single recipients, but can't figure out how to send to multiple, here is my current code for emailing a single user:

 public static void sendCRMNotification(string userGuid, string emailSubject, string emailBody, string recipientType) 

{  

//Set up CRM service
crmService crmservice = GetCrmService();

// Create a FROM activity party for the email.
activityparty fromParty = new activityparty();
fromParty.partyid = new Lookup();
fromParty.partyid.type = EntityName.systemuser.ToString();
fromParty.partyid.Value = new Guid(/*guid of sending user*/);

//Create a TO activity party for email
activityparty toParty = new activityparty();
toParty.partyid = new Lookup();
toParty.partyid.type = EntityName.contact.ToString();
toParty.partyid.Value = new Guid(userGuid);

//Create a new email
email emailInstance = new email();

//set email parameters
emailInstance.from = new activityparty[] { fromParty };
emailInstance.to = new activityparty[] { toParty };
emailInstance.subject = emailSubject;
emailInstance.description = emailBody;

//Create a GUId for the email
Guid emailId = crmservice.Create(emailInstance);

//Create a SendEmailRequest
SendEmailRequest request = new SendEmailRequest();
request.EmailId = emailId;
request.IssueSend = true;
request.TrackingToken = "";

 //Execute request
crmservice.Execute(request);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜灵血窟げ 2024-10-31 16:35:12

这就是我过去所做的。在将其设置为电子邮件属性之前,首先创建数组。

activityparty[] toParty = new activityparty[2];
    toParty[0] = new activityparty();
    toParty[0].partyid = new Lookup(EntityName.contact.ToString(), userGuid);

    toParty[1] = new activityparty();
    toParty[1].partyid = new Lookup(EntityName.contact.ToString(), anotherUserGuid);

    emailMessage.to = toParty;

This is what I have done in the past. Create the array in the beginning before you set it to the email property.

activityparty[] toParty = new activityparty[2];
    toParty[0] = new activityparty();
    toParty[0].partyid = new Lookup(EntityName.contact.ToString(), userGuid);

    toParty[1] = new activityparty();
    toParty[1].partyid = new Lookup(EntityName.contact.ToString(), anotherUserGuid);

    emailMessage.to = toParty;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文