locked
Create Email using template from SDK RRS feed

  • Question

  • Hello,

    I can create email from SDK:

                            Entity fromParty = new Entity("activityparty");
                            fromParty["partyid"] = new EntityReference("systemuser", new Guid(userid));
    
                            Entity Email = new Entity("email");
                            Email.Attributes["from"] = new Entity[] { fromParty };
                            Email.Attributes["subject"] = "Your Order 02";
                            Email.Attributes["regardingobjectid"] = new EntityReference("salesorder", new Guid(orderid));
                            Email.Attributes["description"] = "test";                       
                            Email.Attributes["ownerid"] = new EntityReference("systemuser", new Guid(userid));
                            Guid emailId = connexionCRM.OrgService.Create(Email);

    But i would like to create email from SDH using existing template in CRM:
    I tried to add somethink like that but it's not working. I don't know if it's good and how to link InstantiateTemplateRequest to my Email:

                            Entity fromParty = new Entity("activityparty");
                            fromParty["partyid"] = new EntityReference("systemuser", new Guid(userid));
    
                            InstantiateTemplateRequest instTemplateReq = new InstantiateTemplateRequest
                            {
                                TemplateId = new Guid("30EEC0A3-6726-E611-80F5-005056AA63F9"),
                                ObjectId = new Guid(orderid),
                                ObjectType = "salesorder",
                            };
                            OrganizationResponse r = connexionCRM.OrgService.Execute(instTemplateReq);
    
                            Entity Email = new Entity("email");
                            Email.Attributes["from"] = new Entity[] { fromParty };
                            Email.Attributes["regardingobjectid"] = new EntityReference("salesorder", new Guid(orderid));                    
                            Email.Attributes["ownerid"] = new EntityReference("systemuser", new Guid(userid));
                            Guid emailId = connexionCRM.OrgService.Create(Email);
    I just want to create the email. I don't want to send it
                      

    How can i do ? I would like to keep the Attribute solution and not compiled object.

    Thank you in advance.


    • Edited by KMAREC Monday, May 30, 2016 1:41 PM
    Monday, May 30, 2016 1:26 PM

Answers