gpt4 book ai didi

api - CRM 4.0 使用 API 发送电子邮件时遇到问题...请帮忙!

转载 作者:行者123 更新时间:2023-12-03 02:17:55 25 4
gpt4 key购买 nike

我正在尝试让 CRM 从 .Net C# 应用程序戏剧性地发送电子邮件。我想我已经很接近了,但我不断收到错误:

0x80040203 无法创建事件方:partyid 或 addressused 字段应存在平台

这是我的代码:

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 block 只是重置fromParty。它应该看起来像这样:

//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");

关于api - CRM 4.0 使用 API 发送电子邮件时遇到问题...请帮忙!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5119680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com