Send a Message with Recipients and Attachments

You can use in the bellow code the GetBinding() Method in order to pass as ExchangeService

Attachments are the Full Path to file in HDD

Body is HTML or Plain Text

Recipients are valid E-Mails

CODE – Return true if sent

/// <summary>
/// Envia Mensagem.
/// </summary>
/// <param name="service">The service.</param>
/// <param name="subject">The subject.</param>
/// <param name="body">The body.</param>
/// <param name="mailTo">The mail to.</param>
/// <param name="mailCc"></param>
/// <param name="mailBcc"></param>
/// <param name="attachments"></param>
public static bool SendNewMessage(ExchangeService service, 
                  string subject, string body, 
                  List<string> mailTo, 
                  List<string> mailCc, 
                  List<string> mailBcc, 
                  List<string> attachments)
    // Create an e-mail message and identify the Exchange service.
    EmailMessage message = new EmailMessage(service)
        /* Subject*/
        Subject = subject, /* Body*/
        Body = new MessageBody(body)

    // Recipients
    foreach (string recipientes in mailTo)

    // Recipients
    foreach (string recipientes in mailCc)

    // Recipients
    foreach (string recipientes in mailBcc)

    // Recipients
    foreach (string att in attachments)
    // Send the mail. This makes a trip to the EWS server.
    return true;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s