locked
apply template RRS feed

  • Question

  •  

    I have an email message and with this, I want to create an email but apply a template to the email.

    I can get the template I want, thats fine and returns a valid object. Thats all good but now when I am creating the email request, how can I apply that template?

     

    I've tried following the code in the SDK doc but I get an "unexpected error occured".

     

    InstantiateTemplateRequest instTemplate =
        new InstantiateTemplateRequest();

    // The email template to use.
    instTemplate.TemplateId =
        new Guid("9AF74EF9-A04C-DA11-A0C5-000D9DD8CDAC"); //replaced correctly

    // The object that this email is regarding.
    instTemplate.ObjectId = new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC"); //replaced correctly
    instTemplate.ObjectType = EntityName.account.ToString(); //replaced correctly

    //Uncomment this next line to return dynamic entities.
    //instTemplate.ReturnDynamicEntities = true;

    // Execute the request to create an email message from the template.
    InstantiateTemplateResponse instTemplateResponse =
       (InstantiateTemplateResponse)service.Execute(instTemplate); //here

    Wednesday, August 1, 2007 11:02 AM

Answers

All replies

  • The initial release of CRM had a bug when programmatically using templates (http://support.microsoft.com/kb/912324/) - this was fixed in update rollup 1 - maybe this is your problem, as your code looks OK

    Thursday, August 2, 2007 8:05 AM
    Moderator
  •  

    Thanks, we are actually using Rollup 2 but having this problem
    Thursday, August 2, 2007 10:06 AM
  •  

    Thanks, we are actually using Rollup 2 but having this problem
    Thursday, August 2, 2007 10:24 AM