Class MailUtility
Provides functions for sending email using either Office 365 SMTP service or SharePoint's SendEmail utility
Inheritance
Namespace: PnP.Framework.Utilities
Assembly: PnP.Framework.dll
Syntax
public static class MailUtility : object
Methods
SendEmail(ClientContext, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email using the SharePoint SendEmail method
Declaration
public static void SendEmail(ClientContext context, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body)
Parameters
ClientContext
context
Context for SharePoint objects and operations |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
SendEmail(ClientContext, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email using the SharePoint SendEmail method
Declaration
public static void SendEmail(ClientContext context, IEnumerable<String> to, IEnumerable<String> cc, string subject, string body)
Parameters
ClientContext
context
Context for SharePoint objects and operations |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
SendEmail(String, String, SecureString, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, SecureString fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
SecureString
fromUserPassword
The secure password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmail(String, String, SecureString, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, SecureString fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
SecureString
fromUserPassword
The secure password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmail(String, String, String, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, string fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
System.String
fromUserPassword
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmail(String, String, String, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, string fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The address to use as the sender address |
System.String
fromUserPassword
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmail(String, String, String, SecureString, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, string username, SecureString password, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The address to use as the sender address |
System.String
username
The user setting up the SMTP connection. This user must have an EXO license. |
SecureString
password
The secure password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmail(String, String, String, String, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, string username, string password, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The address to use as the sender address |
System.String
username
The user setting up the SMTP connection. This user must have an EXO license. |
System.String
password
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmail(String, String, String, String, IEnumerable<String>, IEnumerable<String>, String, String, Boolean, Object)
Sends an email via Office 365 SMTP
Declaration
public static void SendEmail(string servername, string fromAddress, string username, string password, IEnumerable<String> to, IEnumerable<String> cc, string subject, string body, bool sendAsync = false, object asyncUserToken = null)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The address to use as the sender address |
System.String
username
The user setting up the SMTP connection. This user must have an EXO license. |
System.String
password
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
System.Boolean
sendAsync
Sends the email asynchronous so as to not block the current thread (default: false). |
System.Object
asyncUserToken
The user token that is used to correlate the asynchronous email message. |
SendEmailAsync(String, String, SecureString, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email via Office 365 SMTP as an asynchronous operation
Declaration
public static async Task SendEmailAsync(string servername, string fromAddress, SecureString fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
SecureString
fromUserPassword
The secure password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
Returns
Task
|
SendEmailAsync(String, String, SecureString, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email via Office 365 SMTP as an asynchronous operation
Declaration
public static async Task SendEmailAsync(string servername, string fromAddress, SecureString fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, string subject, string body)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
SecureString
fromUserPassword
The secure password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
Returns
Task
|
SendEmailAsync(String, String, String, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email via Office 365 SMTP as an asynchronous operation
Declaration
public static async Task SendEmailAsync(string servername, string fromAddress, string fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
System.String
fromUserPassword
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
Returns
Task
|
SendEmailAsync(String, String, String, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email via Office 365 SMTP as an asynchronous operation
Declaration
public static async Task SendEmailAsync(string servername, string fromAddress, string fromUserPassword, IEnumerable<String> to, IEnumerable<String> cc, string subject, string body)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The user setting up the SMTP connection. This user must have an EXO license. |
System.String
fromUserPassword
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
Returns
Task
|
SendEmailAsync(String, String, String, SecureString, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email via Office 365 SMTP as an asynchronous operation
Declaration
public static async Task SendEmailAsync(string servername, string fromAddress, string username, SecureString password, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The address to use as the sender address |
System.String
username
The user setting up the SMTP connection. This user must have an EXO license. |
SecureString
password
The secure password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
Returns
Task
|
SendEmailAsync(String, String, String, String, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, String, String)
Sends an email via Office 365 SMTP as an asynchronous operation
Declaration
public static async Task SendEmailAsync(string servername, string fromAddress, string username, string password, IEnumerable<String> to, IEnumerable<String> cc, IEnumerable<String> bcc, string subject, string body)
Parameters
System.String
servername
Office 365 SMTP address. By default this is smtp.office365.com. |
System.String
fromAddress
The address to use as the sender address |
System.String
username
The user setting up the SMTP connection. This user must have an EXO license. |
System.String
password
The password of the user. |
IEnumerable<String>
to
List of TO addresses. |
IEnumerable<String>
cc
List of CC addresses. |
IEnumerable<String>
bcc
List of BCC addresses. |
System.String
subject
Subject of the mail. |
System.String
body
HTML body of the mail. |
Returns
Task
|