Personalized Community is here!
Quickly customize your community to find the content you seek.
Check out the latest Sales updates!Learn about the key capabilities and features of Dynamics 365 Sales and experience some of the new features.
Download overview guide | Watch Sales video
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Hi,I have created a simple Email Template and used it for send email using c# code, but it will not set From & To activity party fields in email. If I create email without using template, it will create proper with From & To fields.
Here is my code snippets:
Guid templateId = new Guid("1A626841-06A2-E911-A97D-000D3A170740");
Guid contactGuid = new Guid("5B947EB7-DB73-EB11-B1AB-000D3A8C9C58");
Guid userid = new Guid("F6043224-537E-EB11-A812-000D3A8B9E87");
Entity activityParty = new Entity;
activityParty = new Entity("activityparty");
new EntityReference("systemuser", userid);
// activityParty["partyid"] =
//new EntityReference("queue", new Guid(queueIdTurustmaster));
Entity activityParty1 = new Entity;
activityParty1 = new Entity("activityparty");
new EntityReference("contact", contactGuid);
Entity approveemail = new Entity("email");
approveemail.LogicalName = "email";
approveemail["to"] = activityParty1;
approveemail["from"] = activityParty;
approveemail["actualdurationminutes"] = 1;
approveemail["subject"] = "test mail";
string portalURLForContact = "";
SendEmailFromTemplateRequest emailUsingTemplateReq = new SendEmailFromTemplateRequest
Target = approveemail,
TemplateId = templateId,
RegardingId = contactGuid,
RegardingType = "contact"
SendEmailFromTemplateResponse emailUsingTemplateResp = (SendEmailFromTemplateResponse)conn.Execute(emailUsingTemplateReq);
I referred below article: https://www.inogic.com/blog/2017/06/tip-using-sendemailfromtemplaterequest-to-directly-send-an-email-using-the-email-template/
Thank you for your query.
I tried your code, and it worked:
Can you please share a screenshot of your email activity?
Hi Wahaj Rashid,
Above code is working. But I can't change the "From" address. If I want to send email using anyother email address like "email@example.com", I will create a user with "firstname.lastname@example.org" email and set it in "From". But it will still send email from my user that use the plugin or authenticated with. How can I set any other user in "From" property?
It works for me even when I pass a different user's GUID as From (Activity Party):
Please note, I am testing it from a Console App.
Business Applications communities