C# Class PerplexMail.Email

The central class to the email package. It can be configured to send emails.
显示文件 Open project: PerplexInternetmarketing/PerplexMail-for-Umbraco Class Usage Examples

Private Properties

Property Type Description
BuildEmailBody string
DigestCCS void
Email System
Email System
GetContentAsGrid string
GetEmailAdressesFromUmbracoProperty IEnumerable
GetNextLogMailId string
GetTemplateNode Node
Initialize void
IsInlinerDisabled bool
Log int
ProcessHyperlinks void
ProcessImages void
ReplaceTags string
SaveAttachmentsAndGenerateStorageString string

Public Methods

Method Description
ClearLog ( int emailNodeId ) : void
CreateUmbracoEmail ( int umbracoEmailNodeId, List values, IEnumerable attachments ) : Email

Send a email based on the configuration of an Umbraco email node.

DownloadEmail ( int logmailID ) : void
ReSendEmail ( int logmailID, string recipientEmail = null, bool includeCC = false, bool includeBCC = false ) : int

Resend any email that has previously been sent and logged. The email to resend is based on the email log ID, so only emails present in the log table can be resent.

SendEmail ( ) : int

Send the email. The email will also logged automtaically in this call (unless disabled from Umbraco)

SendUmbracoEmail ( int umbracoEmailNodeId ) : int

Send a email based on the configuration of an Umbraco email node.

SendUmbracoEmail ( int umbracoEmailNodeId, List values ) : int

Send a email based on the configuration of an Umbraco email node.

SendUmbracoEmail ( int umbracoEmailNodeId, List values, IEnumerable attachments ) : int

Send a email based on the configuration of an Umbraco email node.

SendUmbracoEmail ( int umbracoEmailNodeId, List values, IEnumerable attachments, System.Net.Mail.MailAddress from, MailAddressCollection replyto, MailAddressCollection to, MailAddressCollection cc, MailAddressCollection bcc ) : int

Send a email based on the configuration of an Umbraco email node. If any email adresses are specified in parameters from, replyto, to, cc or bcc, the email's Umbraco configuration is IGNORED and instead the provided paramter will be used. If any of the email parameters contains NULL, it will be skipped and the email's Umbraco settings will be used instead.

SendUmbracoTestEmail ( SendTestEmailRequest request ) : int

Send a test email based on the settings of the request object. This email is sent exclusively to the specified recipient parameter (CC and BCC are ignored)

SendUmbracoTestEmail ( int umbracoEmailNodeId, IEnumerable recipients, List values ) : int

Send a test email based on the configuration of an Umbraco email node. This email is sent exclusively to the specified recipient parameter (CC and BCC are ignored)

SetSmtpCredentials ( string username, string password ) : void

Protected Methods

Method Description
InlineCSS ( String CSS, HtmlAgilityPack.HtmlDocument &doc ) : void

This method takes raw CSS style code and an HTML document as input and embeds all the specified CSS code in the document. It attempts to apply the styles on the HTML elements in a similar way as you would expect to find in a modern browser. Please take note that CSS3 is not supported and the usage of psuedo elements (:after, :hover, etc) should be avoided. This is because all modern email clients (outlook, gmail) only render basic CSS2 styling as well.

Private Methods

Method Description
BuildEmailBody ( Node nMail ) : string

Loads the unparsed body text for the e-mail and returns it as a single (unparsed) string.

DigestCCS ( List list, string keywordToAdd, string valueToAdd ) : void
Email ( List values = null ) : System
Email ( int umbracoEmailNodeId, List values = null ) : System

Create an email object, but load the basic configuration from an umbraco email node

GetContentAsGrid ( Node nMail ) : string
GetEmailAdressesFromUmbracoProperty ( INode node, EnmUmbracoPropertyAlias alias, bool recursive = true ) : IEnumerable
GetNextLogMailId ( ) : string

Attempt to predict the next logID this e-mail will get. Note: This function is not 100% reliable as emails sent simultaniously may result in the email getting a different (higher) log ID.

GetTemplateNode ( Node nMail ) : Node
Initialize ( List values ) : void
IsInlinerDisabled ( Node nMail ) : bool
Log ( Exception ex = null ) : int
ProcessHyperlinks ( HtmlAgilityPack.HtmlDocument &doc, string mailID ) : void
ProcessImages ( HtmlAgilityPack.HtmlDocument &doc ) : void
ReplaceTags ( string input ) : string
SaveAttachmentsAndGenerateStorageString ( ) : string

Method Details

ClearLog() public static method

public static ClearLog ( int emailNodeId ) : void
emailNodeId int
return void

CreateUmbracoEmail() public static method

Send a email based on the configuration of an Umbraco email node.
public static CreateUmbracoEmail ( int umbracoEmailNodeId, List values, IEnumerable attachments ) : Email
umbracoEmailNodeId int The ID of the configured Umbraco email node
values List List of tags render in the email
attachments IEnumerable The list of attachments that are sent with the email
return Email

DownloadEmail() public static method

public static DownloadEmail ( int logmailID ) : void
logmailID int
return void

InlineCSS() protected static method

This method takes raw CSS style code and an HTML document as input and embeds all the specified CSS code in the document. It attempts to apply the styles on the HTML elements in a similar way as you would expect to find in a modern browser. Please take note that CSS3 is not supported and the usage of psuedo elements (:after, :hover, etc) should be avoided. This is because all modern email clients (outlook, gmail) only render basic CSS2 styling as well.
protected static InlineCSS ( String CSS, HtmlAgilityPack.HtmlDocument &doc ) : void
CSS String The raw CSS code to parse
doc HtmlAgilityPack.HtmlDocument The document to apply the styling to
return void

ReSendEmail() public static method

Resend any email that has previously been sent and logged. The email to resend is based on the email log ID, so only emails present in the log table can be resent.
public static ReSendEmail ( int logmailID, string recipientEmail = null, bool includeCC = false, bool includeBCC = false ) : int
logmailID int The email log ID
recipientEmail string (optioneel) The alternative recipient of the email that will be resent. If left null or empty, the original recipient's emailaddress will be used
includeCC bool Should the email also be sent to the original CC recipients?
includeBCC bool Should the email also be sent to the original CC recipients?
return int

SendEmail() public method

Send the email. The email will also logged automtaically in this call (unless disabled from Umbraco)
public SendEmail ( ) : int
return int

SendUmbracoEmail() public static method

Send a email based on the configuration of an Umbraco email node.
public static SendUmbracoEmail ( int umbracoEmailNodeId ) : int
umbracoEmailNodeId int The ID of the configured Umbraco email node
return int

SendUmbracoEmail() public static method

Send a email based on the configuration of an Umbraco email node.
public static SendUmbracoEmail ( int umbracoEmailNodeId, List values ) : int
umbracoEmailNodeId int The ID of the configured Umbraco email node
values List List of tags render in the email
return int

SendUmbracoEmail() public static method

Send a email based on the configuration of an Umbraco email node.
public static SendUmbracoEmail ( int umbracoEmailNodeId, List values, IEnumerable attachments ) : int
umbracoEmailNodeId int The ID of the configured Umbraco email node
values List List of tags render in the email
attachments IEnumerable The list of attachments that are sent with the email
return int

SendUmbracoEmail() public static method

Send a email based on the configuration of an Umbraco email node. If any email adresses are specified in parameters from, replyto, to, cc or bcc, the email's Umbraco configuration is IGNORED and instead the provided paramter will be used. If any of the email parameters contains NULL, it will be skipped and the email's Umbraco settings will be used instead.
public static SendUmbracoEmail ( int umbracoEmailNodeId, List values, IEnumerable attachments, System.Net.Mail.MailAddress from, MailAddressCollection replyto, MailAddressCollection to, MailAddressCollection cc, MailAddressCollection bcc ) : int
umbracoEmailNodeId int The ID of the configured Umbraco email node
values List List of tags render in the email
attachments IEnumerable The list of attachments that are sent with the email
from System.Net.Mail.MailAddress
replyto MailAddressCollection
to MailAddressCollection
cc MailAddressCollection
bcc MailAddressCollection
return int

SendUmbracoTestEmail() public static method

Send a test email based on the settings of the request object. This email is sent exclusively to the specified recipient parameter (CC and BCC are ignored)
public static SendUmbracoTestEmail ( SendTestEmailRequest request ) : int
request PerplexMail.Models.SendTestEmailRequest The object describing the test email to be sent
return int

SendUmbracoTestEmail() public static method

Send a test email based on the configuration of an Umbraco email node. This email is sent exclusively to the specified recipient parameter (CC and BCC are ignored)
public static SendUmbracoTestEmail ( int umbracoEmailNodeId, IEnumerable recipients, List values ) : int
umbracoEmailNodeId int The ID of the configured Umbraco email node
recipients IEnumerable The emailaddress to receive the test email
values List List of tags render in the email
return int

SetSmtpCredentials() public method

public SetSmtpCredentials ( string username, string password ) : void
username string
password string
return void