CRM 2011 Plugin: Emailing Issue RRS feed

  • Question

  • I have a plugin that is supposed to send an email but it fails on service.Execute(sendEmailreq). The error I get is "Object address not found on party or party is marked as non-emailable". I am using the current logged in user (administrator) which has the primary email address defined and approved.  The user has "Microsoft Dynamics CRM for Outlook" defined for incoming in outgoing (email router is not setup).  I double checked the userGuid to make sure it's really the admin. To eliminate another variable I used the same account for the From and To. The code I am using is as shown below. Any input is appreciated:

    WhoAmIRequest systemUserRequest = new WhoAmIRequest();
    userGuid = ((WhoAmIResponse)service.Execute(systemUserRequest)).UserId;
    ActivityParty fromParty = new ActivityParty {
        PartyId = new EntityReference(SystemUser.EntityLogicalName, userGuid)
    ActivityParty toParty = new ActivityParty {
        PartyId = new EntityReference(SystemUser.EntityLogicalName, userGuid)
    email.To = new ActivityParty[] { toParty };
    email.From = new ActivityParty[] { fromParty };
    emailGuid = service.Create(email);

    SendEmailRequest sendEmailreq = new SendEmailRequest
        EmailId = emailGuid,
        TrackingToken = "",
        IssueSend = true
    SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);

    Monday, July 9, 2012 7:29 AM


All replies

  • Did you check the following blog.
    I always use this code without any error.

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    Linked-In Profile
    Follow me on Twitter!

    • Marked as answer by hfaun Tuesday, July 10, 2012 6:42 AM
    Monday, July 9, 2012 8:13 AM
  • Thanks. I copied the code and just replaced "{entity_name}" with "contact" and for regardingObjectId used the Guid of an existing contact ("Adrian Dumitrascu (sample)" with a new valid yahoo email address) and verified that "Contact Methods - E-mail is set to Allow. It still give me the same error on the Execute command.  

    Considering this, I have a feeling this has something to do with the system user I use for To/From. Which field is being used? Is it the "Primary E-mail", the "Windows Live ID", or something else?

    For the system user I don't see a flag to set email as allowed. I assume this is done by "Approve Email" or is there something else?

    Also at the time of Execute does it matter what the "Email Access Configuration" is? If it does not (because it's put in some queue without checking this) then I can eliminate this as the source.

    Monday, July 9, 2012 3:39 PM
  • I finally figured out the problem. The code actually worked just fine. The issue was that the function WhoAmIRequest did not return the user I expected. It returned the user "SYSTEM". When I hardcoded the GUID for the administrator everything worked.
    Tuesday, July 10, 2012 6:42 AM