Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

Customize Email Sender

Posted on by 20

If an email comes into Dynamics through a Shared email account (ex: sales@mycompany.com), is there a way that when a User of Dynamics responds to the email that the Sender/From address is that of the original shared email account (ex: sales@mycompany.com) and not their User email address that they are signed in under?  If so, can someone point me to JavaScript or Plugin that can do this?  I appreciate the help with this very much.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Customize Email Sender

    Hi Partner,

    Has the problem been solved? Any updates?

    Please click Yes under "Did this answer your question?" to close this thread.

    pastedimage1604568594519v1.png

    Thanks.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Customize Email Sender

    Hi DeVoe1,

    To make building of the request easier to avoid mistakes you can use Crm Rest Builder  

    Download it and import solution to crm.

    https://github.com/jlattimer/CRMRESTBuilder/releases/tag/2.6.0.0

    And the image is clear in my screen, so can you tell me which screenshot is blurry and which step you can’t understand.

    Also, you can try to test js code, the tool is just make request creating easier, you can replace email address with your shared email, the other code shouldn't need to change.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • DeVoe1 Profile Picture
    DeVoe1 20 on at
    RE: Customize Email Sender

    Thank you for such a quick reply to my issue.  Is there any way that you can reply with larger images that aren't blurry so that I can fully understand each step?

    Thanks in advance for your help with this.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Customize Email Sender
    Hi DeVoe1,
    When you reply one email, it will open new email form and some fields will be filled. One field is named Parent Activity Id, which is OOB field and it stores id of the email that you need response.
    In my example, I set a queue with shared email address.
    pastedimage1604392570340v1.png
    Here are steps.
    1. Add Parent Activity Id field to the form, which can make us get id of the received email easily.
    pastedimage1604392604831v2.png
    2.Retrieve received email with ‘Parent Activity Id’ value to get ‘to’ field value.
    pastedimage1604392636481v3.png
    3. Retrieve queue with the email address(to field) to get the queue id, name and type.
    pastedimage1604392656964v4.png
    4.Replace parameters with dynamics value in js:
    function UpdateFromField(executionContext) {
        var formContext = executionContext.getFormContext();
        var lookup = formContext.getAttribute("parentactivityid").getValue();  // recevied email lookup(Parent Activity Id) 
        if (lookup != null) {
            var receviedid = lookup[0].id.slice(1, -1);
    
            Xrm.WebApi.online.retrieveRecord("email", ""   receviedid   "", "?$select=torecipients").then( //get recevied email 'to' field value(email address)
                function success(result) {
                    var torecipients = result["torecipients"];
                    torecipients = torecipients.replace(";","");//remove ; symbol 
                    if (torecipients == "testsharedmailbox@crmxxxxxx.onmicrosoft.com") //only shared email address can update
                    {
                        Xrm.WebApi.online.retrieveMultipleRecords("queue", "?$select=name,queueid,queuetypecode&$filter=emailaddress eq 'testsharedmailbox@crmxxxxxx.onmicrosoft.com'").then(
                            function success(results) {
                                for (var i = 0; i < results.entities.length; i  ) {
                                    var name = results.entities[i]["name"];
                                    var queueid = results.entities[i]["queueid"];
    
                                    //update from field
                                    var lookup = new Array();
                                    lookup[0] = new Object();
                                    lookup[0].id = queueid;
                                    lookup[0].name = name;
                                    lookup[0].entityType = "queue";
                                    formContext.getAttribute("from").setValue(lookup);//set the lookup value finally
                                }
                            },
                            function (error) {
                                Xrm.Utility.alertDialog(error.message);
                            }
                        );
                    }
                },
                function (error) {
                    Xrm.Utility.alertDialog(error.message);
                }
            );
        }
    }

    5.Test.
    (1) it is received email: 
    pastedimage1604392723547v5.png
    (2) when i click reply button:
    pastedimage1604392729197v6.png

    Note: You can try to use CRM Rest Builder tool, which can create request easily.

    Download page: https://github.com/jlattimer/CRMRESTBuilder

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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