web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Sending E-Mails from C# via OrgService

(0) ShareShare
ReportReport
Posted on by 231

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

I have the same question (0)
  • Verified answer
    DK-25061434-0 Profile Picture
    231 on at

    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans