Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Sending E-Mails from C# via OrgService

Posted on by 225

Hi community,

I'm having issues with sending e-mails from within my plugin, I'm consistently getting an error stating that 'partyobjecttypecode' is NULL:

// incident is the Entity that was changed [LogicalName = incident]
// service is the IOrganizationService
// kuc_primarycontactid is a mandatory Reference to the Entity contact.

Entity email = new Entity("email"); // create new mail email["subject"] = strSubject; email["description"] = strBody; EntityCollection to = new EntityCollection(); EntityReference contact = incident.GetAttributeValue<EntityReference>("kuc_primarycontactid"); // contact Entity party = new Entity("activityparty"); party["partyid"] = contact; to.Entities.Add(party); email["to"] = to; service.Create(email);


--> <Message>Attribute 'partyobjecttypecode' cannot be NULL</Message>

How do I get rid of this error?

*This post is locked for comments

  • Verified answer
    DKasp Profile Picture
    DKasp 225 on at
    RE: Sending E-Mails from C# via OrgService

    Nevermind. I reduced my actual code to this, and now it's working - so my more complex code clearly has some issues that I have to deal with and they're the reason for this issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans