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
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
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
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
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
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
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156