AddRecipient(Address, Name, MsgType)

Adds a recipient to an email message.

Parameters
  • Address. Specifies an email address to add.
  • Name. Specifies the recipient name associated with the email address.
  • MsgType. Specifies the email message field to add the email address to.

    Possible values:

    • TO. Adds the email address to the To field.

    • CC. Adds the email address to the Cc field.

    • BCC. Adds the email address to the Bcc field.

Examples
Copy
// Create a message block.
var myMailObject = CRM.GetBlock("messageblock");

// Display an email form and set an email subject.
myMailObject.DisplayForm = true;
myMailObject.mSubject = "My email subject";

// Set email body and display the Cc and Bcc fields.
myMailObject.mBody = "My email body";
myMailObject.mShowCC = true;
myMailObject.mShowBCC = true;

// Add email recipients to the To, Cc, and Bcc fields.
myMailObject.AddRecipient("training@sagecrm.com","Training","TO");
myMailObject.AddRecipient("support@sagecrm.com","Support","CC");
myMailObject.AddRecipient("manager@sagecrm.com","Manager","BCC");
Response.Write(myMailObject.Execute());

Creates and displays an email form, sets an email subject, and adds recipients to the email message fields.

Copy
// Create a message block.
var myMailObject = CRM.GetBlock("messageblock");

// Hide the email form and set an email subject and body.
myMailObject.DisplayForm = false;
myMailObject.mSubject = "My email subject";
myMailObject.mBody = "My email body";

// Add a recipient to the To field.
myMailObject.AddRecipient("training@sagecrm.com","Training","TO");

// Send the message immediately.
myMailObject.Mode = 2;

// Write the operation output.
Response.Write(myMailObject.Execute());

// Record whether the message has been sent successfully. 
if (myMailObject.mSentOK)
    {
        Response.Write("Email was sent successfully.");
    }
    
else
    {
        Response.Write("An error has occurred. Details: "+myMailObject.mErrorMessage);
    }

Creates a hidden email form, adds a recipient to the To field, sends the email, and records the operation output.