CRM 4.0 使用 API 发送电子邮件时遇到问题...请帮忙!
我正在尝试让 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);
}
}
I am trying to get CRM to send an email melodramatically from a .Net C# app. I think I am close, but I keep getting an error:
0x80040203 Cannot create activity party: either partyid or addressused field should be present Platform
Here is my code:
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
toParty
块只是重置fromParty
。它应该看起来像这样:Your
toParty
block is just resetting thefromParty
. It should look like this: