Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Addressused on email recipient is not working

Posted on by 1,771

I have a plugin which triggers pre-operation on update of email.

In the code I update the address used on the activityparty for a single recipient, and then I update the email.

When the email is sent, however, it still sends to the primary email address (emailaddress1 on Contact) even though I've specified emailaddress3 (even if I hard-code the email address and add it to the addressused it still sends to the primary address).

Code below:

var recipient = ((EntityCollection)email.Attributes["to"]).Entities.FirstOrDefault<Entity>();
var to = (EntityReference)recipient.Attributes["partyid"];
var contact = service.Retrieve("contact", to.Id, new ColumnSet("emailaddress3"));
((EntityCollection)email.Attributes["to"]).Entities[0].Attributes["addressused"] = contact.Attributes["emailaddress3"];
service.Update(email);


System is CRM 2016 on-premises

*This post is locked for comments

  • Verified answer
    Marius Agur Pedersen Profile Picture
    Marius Agur Pedersen 1,771 on at
    RE: Addressused on email recipient is not working

    You have to trigger on the "send" Message, obviously.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans