I am trying to get CRM to send a melody melodically from a .Net C # application. I think I'm near, but I keep getting the error message:
0x80040203 Unable to create activity party: partyid or addressused field must be present
Here is my code:
private static void sendCrmEmail()
{
try
{
CrmService crmservice = GetCrmService(OrganisationName, ServerAddress);
Guid emailID = new Guid();
activityparty fromParty = new activityparty();
fromParty.partyid = new Lookup();
fromParty.partyid.type = EntityName.systemuser.ToString();
fromParty.partyid.Value = new Guid("275462F3-1E73-DF11-828B-0050568F1812");
activityparty toParty = new activityparty();
fromParty.partyid = new Lookup();
fromParty.partyid.type = EntityName.contact.ToString();
fromParty.partyid.Value = new Guid("81AEDF3D-E040-E011-9DA2-000C29E4BD21");
email email = new email();
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);
}
}
source
share