How to send an email with Global email templates through CRM SDK code (C#) ? RRS feed

  • Question

  • Hi,

    Here i am trying to send an email by using Global email templates through CRM SDK code (C#) but it is giving me below error:

    "Invalid entity name GLOBAL while retriving MetaDataCache".

    Please find below code what i am using to send email, Here i am passing "Global" as regardingObjectType.

    private void SendEmailFromTemplate(string regardingObjectType, Guid strTemplateId, Guid strRegardingId, Guid To, Guid From, IPluginExecutionContext context)
    email email = null;
    InstantiateTemplateRequest instTemplate = new InstantiateTemplateRequest();
    Guid templateId = strTemplateId;
    instTemplate.TemplateId = templateId;
    Guid _contactId = strRegardingId;
    instTemplate.ObjectId = _contactId;
    instTemplate.ObjectType = regardingObjectType;
    InstantiateTemplateResponse instTempResp =

    Thank You in advance.

    Thank You, - N -
    Wednesday, October 13, 2010 11:42 AM


All replies

  • I have just tried with below two criteria but no luck, i am still getting error

    If TemplateObjectType = ""
    Error: Platform (0x80040203) - Invalid format of input XML for request InstantiateTemplate: required field 'ObjectType' is missing.

    If TemplateObjectType = "Global"
    Error: Platform (0x80041102) - The entity with a name = 'Global' was not found in the MetadataCache.

    Thank You, - N -
    Wednesday, October 13, 2010 11:58 AM
  • If may seem odd, but I think that Global templates are associated with the systemuser entity, so try:

    TemplateObjectType = "systemuser"

    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Wednesday, October 13, 2010 12:47 PM
  • Thank You David!!

    Yeah you are right, i gave a try with "systemuser" and it was working.

    Thank You, - N -
    Wednesday, October 13, 2010 1:18 PM