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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Send Email to list of emails.

(0) ShareShare
ReportReport
Posted on by

I am creating a C# plugin, and I am having some issues sending an email to a list of emails.

From a workflow activity, I returned a list of emails in a string, but it looks like the OOB Send Email activity requires a lookup for the To/CC/BCC fields.

Is there a way I can accomplish this?

I have tried looking at this sample from Microsoft, but I cannot for the life of me find where the Email class is defined: https://msdn.microsoft.com/en-us/library/hh210217.aspx

Thanks,

*This post is locked for comments

I have the same question (0)
  • prt33k Profile Picture
    6,907 on at
    RE: Send Email to list of emails.

    ah! late reply :)

  • Suggested answer
    prt33k Profile Picture
    6,907 on at
    RE: Send Email to list of emails.
    public void SendEmailToUnresolvedRecipient(IOrganizationService crmService,
    string recipientEmailAddress,
    Guid senderUserId,
    string prmSubject,
    string prmMessageBody)
            {
    
                // Creating Email 'to' recipient activity party entity object
                Entity emailToReciepent = new Entity("activityparty");
    
                // Creating Email 'from' recipient activity party entity object
                Entity emailFromReciepent = new Entity("activityparty");
    
                // Assigning receiver email address to activity party addressused attribute
                emailToReciepent["addressused"] = recipientEmailAddress;
    
                // Setting from user account
                emailFromReciepent["partyid"] = new EntityReference("systemuser", senderUserId);
    
                // Creating Email entity object
                Entity emailEntity = new Entity("email");
    
                // Setting email entity 'to' attribute value
                emailEntity["to"] = new Entity[] { emailToReciepent };
    
                // Setting email entity 'from' attribute value
                emailEntity["from"] = new Entity[] { emailFromReciepent };
    
                // Setting email subject and description
                emailEntity["subject"] = prmSubject;
    
                emailEntity["description"] = prmMessageBody;
    
                // Creating email record
                Guid emailId = crmService.Create(emailEntity);
    
                // Creating SendEmailRequest object for sending email
                SendEmailRequest sendEmailreq = new SendEmailRequest
                {
                    EmailId = emailId,
                    TrackingToken = "",
                    IssueSend = true
                };
    
                SendEmailResponse sendEmailresp = (SendEmailResponse)crmService.Execute(sendEmailreq);
    
            }

    This should work..

    Prateek

  • Community Member Profile Picture
    on at
    RE: Send Email to list of emails.

    Thank you so much for your help!

    The problem was that the to/from/cc/bcc list required an Entity of type activityparty. The late-bound example made this clear to me.

  • Verified answer
    ashlega Profile Picture
    34,477 on at
    RE: Send Email to list of emails.

    Hi,

     you need to generate those early-bound classes first:

    msdn.microsoft.com/.../gg327844.aspx

     If you wanted to use late-bound, there is an example here:

    mubashersharif.blogspot.ca/.../send-email-using-late-binding-crm-2011.html

      As for the lookup vs plain text address, you can configure what's allowed if you go to Settings->Administration->System Settings->Email->"Allow messages with unresolved email recipients to be sent"

     Once you've configured that option, you can use this as an example:

    paul-way.com/sending-unresolved-emails

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans