让CRM 4.0使用API发送电子邮件时遇到问题。。。请帮忙!
我试图让CRM从.Net C#应用程序发送一封戏剧性的电子邮件。我想我很接近了,但我不断地得到一个错误: 0x80040203无法创建活动参与方:partyid或addressused字段应存在 这是我的密码:让CRM 4.0使用API发送电子邮件时遇到问题。。。请帮忙!,api,email,dynamics-crm,crm,Api,Email,Dynamics Crm,Crm,我试图让CRM从.Net C#应用程序发送一封戏剧性的电子邮件。我想我很接近了,但我不断地得到一个错误: 0x80040203无法创建活动参与方:partyid或addressused字段应存在 这是我的密码: private static void sendCrmEmail() { try { //Set up the service CrmService crmservice = GetCrmService(OrganisationName,
private static void sendCrmEmail()
{
try
{
//Set up the service
CrmService crmservice = GetCrmService(OrganisationName, ServerAddress);
Guid emailID = new Guid();
// 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("275462F3-1E73-DF11-828B-0050568F1812");
//Create a TO activity party for email
activityparty toParty = new activityparty();
fromParty.partyid = new Lookup();
fromParty.partyid.type = EntityName.contact.ToString();
fromParty.partyid.Value = new Guid("81AEDF3D-E040-E011-9DA2-000C29E4BD21");
// Create an email message.
email email = new email();
// Set email properties
email.to = new activityparty[] { fromParty };
email.from = new activityparty[] { toParty };
email.subject = "subject";
email.description = "body";
CrmBoolean direction = new CrmBoolean();
direction.Value = true;
email.directioncode = direction;
TargetCreateEmail targetCreate = new TargetCreateEmail();
targetCreate.Email = email;
CreateRequest request = new CreateRequest();
request.Target = targetCreate;
CreateResponse response = (CreateResponse)crmservice.Execute(request);
emailID = response.id;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
Console.WriteLine(ex.Detail.InnerText);
}
}
您的
toParty
块正在重置来自party的。应该是这样的:
//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("81AEDF3D-E040-E011-9DA2-000C29E4BD21");