【问题标题】:Using CRM 4.0 SDK to send emails to multiple contacts at once使用 CRM 4.0 SDK 一次向多个联系人发送电子邮件
【发布时间】:2011-03-21 14:07:28
【问题描述】:

是否可以发送一封在“收件人”字段中指定了多个电子邮件地址的电子邮件?我让它适用于单个收件人,但不知道如何发送给多个收件人,这是我当前用于向单个用户发送电子邮件的代码:

 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);
}

【问题讨论】:

    标签: email crm dynamics-crm-4


    【解决方案1】:

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

    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;
    

    【讨论】:

    • 谢谢bweaver,我试试看!
    猜你喜欢
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    相关资源
    最近更新 更多