【发布时间】:2014-05-01 15:19:34
【问题描述】:
我正在尝试通过 crm 发送 n 封电子邮件,但正文中包含 HTML。我正在通过 CRM 正确发送电子邮件,但是当我打开它(联系人 > 历史记录)时,我打开电子邮件并看到正文没有将 XML 编码为 HTML。这是我到目前为止所拥有的。我的电子邮件正文在此代码下方。我已经使用 MailMessage() 完成了此操作,但这不会通过 CRM 发送,只能通过 SMTP。有什么想法吗?
var emailTemplateBody = GetEmailTemplateBody();
var _getEmailVariables = getEmailVariables(emailTemplateBody);
// 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("C82755FB-6369-DB11-98AE-00145E7F535F");
//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("74CD3907-5BC9-E311-9C41-005056850017");
//Create a new email
email emailInstance = new email();
//set email parameters
emailInstance.from = new activityparty[] { fromParty };
emailInstance.to = new activityparty[] { toParty };
emailInstance.subject = "Who Cares";
emailInstance.description = _getEmailVariables;
emailInstance.mimetype = ""
//Create a GUId for the email
Guid emailId = _crmServiceInstance.Create(emailInstance);
//Create a SendEmailRequest
SendEmailRequest request = new SendEmailRequest();
request.EmailId = emailId;
request.IssueSend = true;
request.TrackingToken = "";
//Execute request
_crmServiceInstance.Execute(request);
需要在 HTML 中的 XML 代码:
"<template><text><![CDATA[<p><font size=2 face=\"Tahoma, Verdana, Arial\">Hi: |contact.FullName|</font></p>\r\n<p><font size=2 face=\"Tahoma, Verdana, Arial\"></font> </p><font size=2 face=\"Tahoma, Verdana, Arial\">\r\n<ul style=\"list-style-type:disc;white-space:normal;word-spacing:0px;text-transform:none;color:rgb(0,0,0);padding-bottom:0px;text-align:left;padding-top:0px;font:14px/19px 'Helvetica Neue', Arial, Helvetica;padding-left:20px;margin:0px 0px 10px 10px;letter-spacing:normal;padding-right:0px;background-color:rgb(255,255,255);text-indent:0px\">\r\n<li style=\"list-style-position:outside;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:5px 0px;padding-right:0px\">Content Line 2 = |New_manheimsubscription.new_externalbillingsubscriptionid| \r\n<li style=\"list-style-position:outside;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:5px 0px;padding-right:0px\">DogButter is gross</li></ul></font>]]></text></template>"
【问题讨论】: