i'm unable to send an email to another user using plugin in dynamics crm 2013? RRS feed

  • Question

  • i'm trying send an email to another user using plugin.it shows that user id does not exists.could any references helpfull

    Below is my Code:

      EntityReference to = new EntityReference("systemuser",getid); here i'm getting error id does not exists.this id is another user id.
    if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                    Entity en=(Entity)context.InputParameters["Target"];
                    Entity email = new Entity("email");
                    email.Attributes["subject"] = "Case Needs to be Closed";
                    email.Attributes["description"] = "Case";
                    email.Attributes["regardingobjectid"] = new EntityReference(en.LogicalName,en.Id);
                    EntityReference from = new EntityReference("systemuser", context.UserId);
                    Guid getid = new Guid("3324328F-E0F6-E311-80C2-D89D6765A2DC");
                    EntityReference to = new EntityReference("systemuser",getid);
                    Entity fromparty = new Entity("activityparty");
                    fromparty.Attributes["partyid"] = from;
                    Entity toparty=new Entity("activityparty");
                    toparty.Attributes["partyid"] = to;
                    EntityCollection frmPartyCln = new EntityCollection();
                    frmPartyCln.EntityName = "systemuser";
                    EntityCollection toPartyCln = new EntityCollection();
                    toPartyCln.EntityName = "systemuser";
                    email.Attributes.Add("from", frmPartyCln);
                    email.Attributes.Add("to", toPartyCln);
                    //Create an EMail Record
                    Guid _emailId = service.Create(email);
                    // Use the SendEmail message to send an e-mail message.
                    SendEmailRequest sendEmailreq = new SendEmailRequest
                        EmailId = _emailId,
                        TrackingToken = "",
                        IssueSend = true
                    SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);
    Any references appreciated.

    hsk srinivas

    • Edited by Ppandu Monday, June 23, 2014 12:00 PM
    Monday, June 23, 2014 12:00 PM

All replies

  • Hi,

    The error states that the User with that Id doesn't exist. Have you double checked that the GUID is correct? Also, make sure the User has an Email address and has allowed Emails.

    Admin QuikView Solution for CRM 2013

    Tuesday, June 24, 2014 10:25 AM
  • Guid is Correct.where should i have to check allowed emails

    hsk srinivas

    Tuesday, June 24, 2014 11:17 AM
  • Check the security role

    Under Business Management

    Check Permission Send Email as another User.

    Regards Faisal

    Tuesday, June 24, 2014 1:05 PM