0
我正嘗試在crm2011中創建併發送電子郵件請求。我有電子郵件,但是當我嘗試發送電子郵件時,我收到一個例外情況:試圖發送電子郵件請求,但我得到異常
帶ID = 00000000-0000-0000-0000-000000000000的電子郵件不存在。
這裏是我的代碼:
OrganizationServiceProxy p = new OrganizationServiceProxy(
new Uri(""), null, ccr, null);
WhoAmIRequest systemUserRequest = new WhoAmIRequest();
WhoAmIResponse systemUserResponse = (WhoAmIResponse)p.Execute(systemUserRequest);
Guid _userId = systemUserResponse.UserId;
Entity email = new Entity("email");
email.Attributes.Add("subject", "test");
Entity[] To = new Entity[1];
To[0] = new Entity("activityparty");
To[0]["partyid"] = new EntityReference("contact", new Guid("some guidid"));
email.Attributes.Add("to", To);
Entity[] From = new Entity[1];
From[0] = new Entity("activityparty");
From[0]["partyid"] = new EntityReference("systemuser", _userId);
email.Attributes.Add("from", From);
try
{
Guid emailGuid = p.Create(email);
}
catch (Exception e)
{
Console.WriteLine("error " + e.Message);
Console.ReadLine();
}
OrganizationRequest request = new OrganizationRequest() { RequestName = "SendEmail" };
request["EmailId"] = email.Id;
request["TrackingToken"] = "";
request["IssueSend"] = true;
// THE CODE FAILS HERE:
OrganizationResponse rsp = p.Execute(request);
你得到一個空的Guid'00000000-0000-0000-0000-000000000000',而不是一個有效的。你檢查了這個原因嗎? – Saravanan