2011-02-25 2 views
3

CRM에서 .Net C# 앱을 통해 멜로 드라마로 이메일을 보내려고합니다. 내가 가까이라고 생각하지만 오류가 점점 계속 :CRM 4.0이 API를 사용하여 전자 메일을 보내는데 문제가 발생했습니다 ... 제발 도와주세요!

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); 
    } 


} 

답변

2

귀하의 toParty 차단은 단지 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"); 
+0

OMG ... 나는 휴가 LOL이 필요합니다. 더 이상 오류가 없습니다. – PercivalMcGullicuddy

관련 문제