Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Associating incoming emails to existing records ("set regarding")

Posted on by Microsoft Employee

Hi all - I have a simple requirement, I'm wondering if the only way to implement it is to write custom code, I was hoping for out-of-the-box:

  1. I have a custom entity (Employee) that has an "email" field
  2. I have a queue that receives emails
  3. When the queue receives an email, I want to automatically "set regarding" to the Employee who sent it

To make this clear:

  • There's a queue that receives emails on "hr@contoso.com"
  • The employee "john.smith@contoso.com" sends an email to "hr@contoso.com"
  • John Smith is not a user of the system, but there's an employee record "John Smith" with its email set to "john.smith@contoso.com"
  • I want the received email to have the "regarding" field set to "John Smith".

Is there a way to do this only through configuration?

Thank you!!

*This post is locked for comments

  • Tim Dutcher Profile Picture
    Tim Dutcher 2,100 on at
    RE: Associating incoming emails to existing records ("set regarding")

    Excellent! A little code goes a long way.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Associating incoming emails to existing records ("set regarding")

    Thanks Tim - so few updates for whomever happens to stumble on this in the future:

    1. This should be a feature, all the pieces are there already - when an email is received, the system already does the matching and finds the corresponding employee record, which is then linked back to the email through activityparty
    2. There is a "from" attribute in the email (which you can select from a workflow) that is automatically populated with the correct entity (in this case an Employee entity)
    3. Unfortunately you can't use it in a workflow, because the workflow does not know what that party is (is it a user? a contact? etc.)

    So the solution is indeed to write some code, HOWEVER Hassan's response can be enhanced: you don't need to search and match the email address, it is already matched. In fact you can do the whole task in four lines of code (assuming you're crazy enough not to do some checks). Here's how.

    Assuming you have an email record (emailRecord) of which you want to update the Regarding field based on the From field:

    var from = (EntityCollection)emailRecord["from"];
    var activityparty = from.Entities[0];
    var partyid = (EntityReference)activityparty["partyid"];
    emailRecord["regardingobjectid"] = partyid;
    

    Ta. Done.

  • Verified answer
    Tim Dutcher Profile Picture
    Tim Dutcher 2,100 on at
    RE: Associating incoming emails to existing records ("set regarding")

    This thread is related and the response (by Hassan) still applies:

    social.microsoft.com/.../regarding-inside-emails

    By the way, your question is very well written. Thumbs up on quality and completeness.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans