Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
Unanswered

Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

Posted on by 619

Hi All,

I am using Dynamics CRM 2016 - On-Premise for development. I am doing customization for email to case creation and after create case, sending mail to customer about case details. For this, I am not using Queue management to create case. Because before create case, I have to check whether incoming mail address is in existing account or if contact matching with the sending mail address, retrieving contact parent customer as case customer. If nothing is matching, some default customer has to be set in case customer. Hope this validation is not exist in Queue to case creation. So, I am doing it manually.

I am sending mail to customer manually after create case by using plug in assembly. Whenever I am sending mail manually the tracking token is same for all the mail as CRM:0000001.  Means, if I am sending mail through workflow it is taking the latest tracking token for eg., CRM:0195101. So when i am getting reply from customer, i can track with this tracking token. But for manually through code, it is taking all the time CRM:0000001. I am using below code for sending mail

SendEmailRequest sendEmailRequest = new SendEmailRequest();
sendEmailRequest.EmailId = emailId;
sendEmailRequest.IssueSend = true;
sendEmailRequest.TrackingToken = "";
SendEmailResponse sendEmailResponse = (SendEmailResponse)service.Execute(sendEmailRequest);

In this, i tried with GetTrackingTokenEmailRequest method also. But same issue.

Kindly help to fix the problem

Thanks,

Saratha

  • Saratha Profile Picture
    Saratha 619 on at
    RE: Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

    Hi Pankaj,

    Thank you for your follow up. In the plugIn code, I have done the same thing as I mentioned below. But it's not working. As you told, I am not a non interactive user. Other than non interactive user, how to get the incremented tracking token.

    SendEmailRequest sendEmailRequest = new SendEmailRequest();

    sendEmailRequest.EmailId = emailId;

    sendEmailRequest.IssueSend = true;

    sendEmailRequest.TrackingToken = "";

    SendEmailResponse sendEmailResponse = (SendEmailResponse)service.Execute(sendEmailRequest);

    Thanks,

    Saratha

  • Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

    Hi Saratha,

    Can you use a console application to execute the code and see if the token is incremented.

    Entity fromActivityParty = new Entity("activityparty");
    Entity toActivityParty = new Entity("activityparty");
    
    Guid contactId = (Guid)a.Attributes["contactid"];
    
    fromActivityParty["partyid"] = new EntityReference("systemuser", new Guid("1568d957-50ac-473a-9883-163456849c0c"));
    toActivityParty["partyid"] = new EntityReference("contact", contactId);
    
    Entity email = new Entity("email");
    email["from"] = new Entity[] { fromActivityParty };
    email["to"] = new Entity[] { toActivityParty };
    email["regardingobjectid"] = new EntityReference("contact", contactId);
    email["subject"] = "This is the subject";
    email["description"] = "This is the description.";
    email["directioncode"] = true;
    Guid emailId = _crmServiceClient.Create(email);
    
    // Use the SendEmail message to send an e-mail message.
    SendEmailRequest sendEmailRequest = new SendEmailRequest
    {
        EmailId = emailId,
        TrackingToken = "",
        IssueSend = true
    };
    
    SendEmailResponse sendEmailresp = (SendEmailResponse)_crmServiceClient.Execute(sendEmailRequest);
    Console.WriteLine("Email sent");
    Console.ReadLine();

    Best Regards

    PG

  • Saratha Profile Picture
    Saratha 619 on at
    RE: Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

    Hi Pankaj,

    I am not using workflow for send mail. When queue item creating, I am triggering plugIn. I am taking the object id of queue item if it is mail type. I am creating the case through code only. From mail, I am taking the sender mail id (From address used) and after create case, sending mail to customer with case details. "SendMailRequest" using for send mail.

    Thanks,

    Saratha

  • Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

    Hi Saratha,

    How are you invoking the workflow, is it within the user context or as the owner of the workflow. I suggest using the user context.

    Best Regards

    PG

  • Saratha Profile Picture
    Saratha 619 on at
    RE: Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

    Hi Pankaj,

    Thank you for your response. Only regular user will get the incremented Tracking Token?  Is it possible, admin user can get the incremented tracking token. Or apart from this, any other way to get the latest token.

    Thanks,

    Saratha

  • Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

    Hi Saratha,

    Here is what the document says.

    "When this API generates a tracking token, the API is designed to return an auto incrementing tracking token when the caller is a regular user. The API returns a static token "1" formatted in the configured organization-level tracking token format when the caller is a special system user: SYSTEM, INTEGRATION USER"

    docs.microsoft.com/.../microsoft.crm.sdk.messages.sendemailrequest.trackingtoken

    Are you calling this as a regular user?

    Hope this helps

    Best Regards

    PG

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans