使用MS Dynamics Web API创建邮件时sender与torecipients字段不生效求助
Hey there, I’ve run into this exact issue before! The problem is that sender and torecipients aren’t simple string fields in Dynamics CRM’s email entity—they require proper entity references or activity party collections to work correctly. Here’s what you’re missing:
Why Your Current Payload Isn’t Working
When you pass raw email strings like "sender": "test@test.com", CRM doesn’t recognize them because:
- The
senderfield expects a reference to a CRM record (like asystemuserorcontact), not just an email address. torecipientsmaps to theemail_activity_partiesnavigation property, which is a collection ofactivitypartyrecords that define who’s receiving the email, along with their role (To/CC/BCC).
Correct Payload Format
Let’s break down the fix with examples:
1. Linking a Sender (CRM User/Contact)
Use @odata.bind to associate the sender with an existing CRM record:
- For a system user:
"sender@odata.bind": "/systemusers(YOUR_USER_GUID)" - For a contact:
"sender@odata.bind": "/contacts(YOUR_CONTACT_GUID)"
2. Adding To Recipients
Use the email_activity_parties array to define each recipient. You can link existing CRM records or add external email addresses directly:
Option A: Link Existing CRM Records
{ "subject": "Test Subject New 1234567", "description": "Test Description New 1234567", "sender@odata.bind": "/systemusers(00000000-0000-0000-0000-000000000001)", "email_activity_parties": [ { // Link a system user as To recipient "partyid_systemuser@odata.bind": "/systemusers(00000000-0000-0000-0000-000000000002)", "participationtypemask": 2 // 2 = To recipient }, { // Link a contact as To recipient "partyid_contact@odata.bind": "/contacts(00000000-0000-0000-0000-000000000003)", "participationtypemask": 2 } ] }
Option B: Add External Email Addresses (Not in CRM)
If you need to send to someone not in your CRM instance, use the addressused field in the activity party:
{ "subject": "Test Subject New 1234567", "description": "Test Description New 1234567", "sender@odata.bind": "/systemusers(00000000-0000-0000-0000-000000000001)", "email_activity_parties": [ { "addressused": "test2@test.com", "participationtypemask": 2 } ] }
Key Notes
- participationtypemask values: These define the recipient role:
- 1 = Sender
- 2 = To
- 3 = CC
- 4 = BCC
- Always use valid GUIDs for existing CRM records. You can fetch these via the Web API if you don’t have them handy.
- For external recipients, creating a
contactrecord first (and linking it) is better for tracking and reporting in CRM.
Once you adjust your payload to follow this structure, the sender and to recipients will show up correctly in Dynamics CRM!
内容的提问来源于stack exchange,提问作者Parth Trivedi

