Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to send email to both email ids of a contact in single email though Code

(0) ShareShare
ReportReport
Posted on by 647

Hi,

We have contact entity with two email fields available per contact. How to send  single email by appending multiple email address at time. Using below code was able to get only one email id field.

private void SendEmail(Guid accountToGuid)

{

Entity toParty = new Entity("activityparty");

toParty["partyid"] = new EntityReference("contact", accountToGuid);

 

}

*This post is locked for comments

  • Integration Profile Picture
    Integration 647 on at
    RE: How to send email to both email ids of a contact in single email though Code

    Thanks guys it worked..

    if (item.Attributes["emailaddress1"]!=null)

                               {

                                   toParty["addressused"] = item.Attributes["emailaddress1"].ToString();

                                   toParty["partyid"] = new EntityReference("contact", receiverUID);

                                   toPartyArray.Add(toParty);

                                   collToParty.Entities.Add(toParty);

                                   EmailAddress = string.Empty;

                               }

                               Entity toParty1 = new Entity("activityparty");

                               if (item.Attributes["emailaddress2"] != null)

                               {                                

                                   toParty1["addressused"] = item.Attributes["emailaddress2"].ToString();

                                   toParty1["partyid"] = new EntityReference("contact", receiverUID);

                                   toPartyArray.Add(toParty1);

                                   collToParty.Entities.Add(toParty1);

                                   EmailAddress = string.Empty;

                               }

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: How to send email to both email ids of a contact in single email though Code

    Hi Krish,

    If you set the entity reference object for the Party then CRM will send teh email to the primary email. If you want multiple email, then you need to use the"addressused" field of the party. Refer below blog-

    paul-way.com/sending-unresolved-emails

    Hope this helps.

  • Verified answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,231 on at
    RE: How to send email to both email ids of a contact in single email though Code

    Hi Krish,

    You need to create entitycollection object to pass multiple email address into 'To' party. Please do refer following code for reference:

    EntityCollection collToParty = new EntityCollection();

    Entity toParty = new Entity("activityparty");

    string EmailAddress = Contact.Attributes.Contains("emailaddress") ? (string)Contact.Attributes["emailaddress"] : string.Empty;

    if (EmailAddress != string.Empty)

    {

    toParty["addressused"] = EmailAddress;

    toParty["partyid"] = new EntityReference("systemuser", User.Id);

    toPartyArray.Add(toParty);

    }

    collToParty.Entities.Add(toParty);

    Entity Email = new Entity("email");

    Email.Attributes.Add("to", collToParty);

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    Temmy Wahyu Raharjo 2,914 on at
    RE: How to send email to both email ids of a contact in single email though Code

    Hi,

    This is not possible to do because the design for this one is base on Activity Entity (it will take one attribute name emailaddress). For your requirement you need to create child entity (need to be activity). Then on your plugin that one, you need to retrieve and add all the child entity to the email to/cc/bcc.

    Hope this help.

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: How to send email to both email ids of a contact in single email though Code

    You can use one address in "To" and second one is in "CC". To achieve this functionality, You have to write a plug-in or workflow, below is link for your help:

    community.dynamics.com/.../sending-email-to-an-alternate-secondary-email-address

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans