Creatio development guide
PDF
This documentation is valid for Creatio version 7.15.0. We recommend using the newest version of Creatio documentation.

Sending emails from existing accounts

Glossary Item Box

Introduction

In Creatio, you can send emails using both, customer and developer means. With the developer means, you can send emails:

  • Using an existing account
  • Using the explicit account credentials

This article covers sending emails from existing accounts. Read more about sending emails using your account credentials in the “Sending emails using the explicit account credentials" article.

Preparing and sending an email

To send an email from an existing account:

  1. Create a config file of the email.
  2. Add an attachment (if applicable).
  3. Perform sending.

Creating a config file of the email

To create a configuration file of the email, use the Terrasoft.Mail.Sender.EmailMessage class. Populate the below parameters to ensure the validity of your email:

var message = new Terrasoft.Mail.Sender.EmailMessage {
    // Senders' email addresses.
    From = "Sender@email.com",
    // Recipients' email addresses.
    To = List<string>{ "first@recepient.co", "second@recepient.co"},
    // Copy (if applicable).
    Cc = List<string>{ "first@recepient.co", "second@recepient.co"},
    // Carbon copy (if applicable).
    Bcc = List<string>{ "first@recepient.co", "second@recepient.co"},
    // Email subject.
    Subject = "Message subject",
    // Email body.
    Body = "Body",
    // Priority, the Terrasoft.Mail.Sender.EmailPriority enumeration values.
    Priority = Terrasoft.Mail.Sender.EmailPriority.Normal
};

Adding attachments (if applicable)

Additionally, you can add attachments to your email. To do this, populate the [Attachments] field. Attachments are basically a list of Terrasoft.Mail.Sender.Attachments instances.

// Creating an attachment.
var attachment = new Terrasoft.Mail.Sender.EmailAttachment {
    // Attachment identification.
    Id = new Guid("844F0837-EAA0-4F40-B965-71F5DB9EAE6E"),
    // Attachment name.
    Name = "attachName.txt",
    // Data.
    Data = byteData
};
// Adding attachment to the email.
message.Attachments.Add(attachment);

Sending the email

To send the email, use the Send method of the EmailSender class with the parameters of the email and the connection configuration file.

// Sending the generated email. To ignore the access permissions when sending the email,
// set the ignoreRights parameter value to "true".
emailSender.Send(message, ignoreRights);
© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?