C# Class SendGrid.Mail

Inheritance: IMail
Mostra file Open project: advancedrei/sendgridplus-csharp

Public Methods

Method Description
AddAttachment ( Stream stream, string name ) : void

Add a stream as an attachment to the message

AddAttachment ( Stream stream, string name, string contentType ) : void

Add a stream as an attachment to the message

AddAttachment ( Stream stream, string name, string contentType, string contentId ) : void

Add a stream as an attachment to the message

AddAttachment ( string filePath ) : void

Add an attachment to the message.

AddBcc ( string>.IDictionary addresssInfo ) : void

Add to the 'Bcc' address.

AddBcc ( IEnumerable addresses ) : void

Add to the 'Bcc' address.

AddBcc ( string address ) : void

Add to the 'Bcc' address.

AddCc ( string>.IDictionary addresssInfo ) : void

Add to the 'CC' address.

AddCc ( IEnumerable addresses ) : void

Add to the 'CC' address.

AddCc ( string address ) : void

Add to the 'CC' address.

AddHeaders ( string>.IDictionary headers ) : void

Add custom headers to the message

AddSubstitution ( string replacementTag, List substitutionValues ) : void

Defines a mapping between a replacement string in the text of the message to a list of substitution values to be used, one per each recipient, in the same order as the recipients were added.

AddTo ( string>.IDictionary addresssInfo ) : void

Add to the 'To' address.

AddTo ( IEnumerable addresses ) : void

Add to the 'To' address.

AddTo ( string address ) : void

Add to the 'To' address.

AddUniqueIdentifiers ( string>.IDictionary identifiers ) : void

This adds parameters and values that will be passed back through SendGrid's Event API if an event notification is triggered by this email.

CreateMimeMessage ( ) : MailMessage

Used by the Transport object to create a MIME for SMTP

DisableBcc ( ) : void

Disable Bcc app

DisableBypassListManagement ( ) : void

Disable the Bypass List Management app

DisableClickTracking ( ) : void

Disable the click tracking app

DisableFooter ( ) : void

Disable the footer app

DisableGoogleAnalytics ( ) : void

Disable the Google Analytics app

DisableGravatar ( ) : void

Disable the gravatar app

DisableOpenTracking ( ) : void

Disable the open tracking app

DisableSpamCheck ( ) : void

Disable the spam check

DisableTemplate ( ) : void

Disable the templates app

DisableUnsubscribe ( ) : void

Disable the unsubscribe app

EnableBcc ( string email ) : void

Automatically sends a blind carbon copy to an address for every e-mail sent, without adding that address to the header.

EnableBypassListManagement ( ) : void

Enabing this app will bypass the normal unsubscribe / bounce / spam report checks and queue the e-mail for delivery.

EnableClickTracking ( bool includePlainText = false ) : void

Causes all links to be overwritten, shortened, and pointed to SendGrid's servers so clicks will be tracked.

EnableFooter ( string text = null, string html = null ) : void

Attaches a message at the footer of the email

EnableGoogleAnalytics ( string source, string medium, string term, string content = null, string campaign = null ) : void

Re-writes links to integrate with Google Analytics

EnableGravatar ( ) : void

Inserts the gravatar image of the sender to the bottom of the message

EnableOpenTracking ( ) : void

Adds an invisible image to the end of the email which can track e-mail opens.

EnableSpamCheck ( int score = 5, string url = null ) : void

Provides notification when emails are detected that exceed a predefined spam threshold.

EnableTemplate ( string html ) : void

Wraps an HTML template around your email content.

EnableUnsubscribe ( string replace ) : void

Allows SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender

EnableUnsubscribe ( string text, string html ) : void

Allows SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender

GetInstance ( ) : Mail

Creates an instance of SendGrid's custom message object

GetInstance ( MailAddress from, MailAddress to, MailAddress cc, MailAddress bcc, string subject, string html, string text ) : Mail

Creates an instance of SendGrid's custom message object with mail parameters

GetRecipients ( ) : IEnumerable

GetRecipients returns a list of all the recipients by retrieving the to, cc, and bcc lists.

SetCategories ( IEnumerable categories ) : void

SetCategory ( string category ) : void

This sets the category for this email. Statistics are stored on a per category basis, so this can be useful for tracking on a per group basis.

Private Methods

Method Description
InitializeFilters ( ) : string>.Dictionary
Mail ( IHeader header ) : System
Mail ( MailAddress from, MailAddress to, MailAddress cc, MailAddress bcc, string subject, string html, string text, IHeader header = null ) : System
SaveMessage ( string directory ) : void

Helper function lets us look at the mime before it is sent

Method Details

AddAttachment() public method

Add a stream as an attachment to the message
public AddAttachment ( Stream stream, string name ) : void
stream Stream Stream of file to be attached
name string Name of file to be attached
return void

AddAttachment() public method

Add a stream as an attachment to the message
public AddAttachment ( Stream stream, string name, string contentType ) : void
stream Stream Stream of file to be attached
name string Name of file to be attached
contentType string Content type of stream
return void

AddAttachment() public method

Add a stream as an attachment to the message
public AddAttachment ( Stream stream, string name, string contentType, string contentId ) : void
stream Stream Stream of file to be attached
name string Name of file to be attached
contentType string Content type of stream
contentId string ContentId for embedding images
return void

AddAttachment() public method

Add an attachment to the message.
public AddAttachment ( string filePath ) : void
filePath string a fully qualified file path as a string
return void

AddBcc() public method

Add to the 'Bcc' address.
public AddBcc ( string>.IDictionary addresssInfo ) : void
addresssInfo string>.IDictionary the dictionary keys are the email addresses, which points to a dictionary of /// key substitutionValues pairs mapping to other address codes, such as { [email protected] => { 'DisplayName' => 'Mr Foo' } }
return void

AddBcc() public method

Add to the 'Bcc' address.
public AddBcc ( IEnumerable addresses ) : void
addresses IEnumerable a list of emails as an array of strings.
return void

AddBcc() public method

Add to the 'Bcc' address.
public AddBcc ( string address ) : void
address string a single email as the input eg "[email protected]"
return void

AddCc() public method

Add to the 'CC' address.
public AddCc ( string>.IDictionary addresssInfo ) : void
addresssInfo string>.IDictionary the dictionary keys are the email addresses, which points to a dictionary of /// key substitutionValues pairs mapping to other address codes, such as { [email protected] => { 'DisplayName' => 'Mr Foo' } }
return void

AddCc() public method

Add to the 'CC' address.
public AddCc ( IEnumerable addresses ) : void
addresses IEnumerable a list of email addresses as strings
return void

AddCc() public method

Add to the 'CC' address.
public AddCc ( string address ) : void
address string a single email address eg "[email protected]"
return void

AddHeaders() public method

Add custom headers to the message
public AddHeaders ( string>.IDictionary headers ) : void
headers string>.IDictionary key substitutionValues pairs
return void

AddSubstitution() public method

Defines a mapping between a replacement string in the text of the message to a list of substitution values to be used, one per each recipient, in the same order as the recipients were added.
public AddSubstitution ( string replacementTag, List substitutionValues ) : void
replacementTag string the string in the email that you'll replace eg. '-name-'
substitutionValues List a list of values that will be substituted in for the replacementTag, one for each recipient
return void

AddTo() public method

Add to the 'To' address.
public AddTo ( string>.IDictionary addresssInfo ) : void
addresssInfo string>.IDictionary the dictionary keys are the email addresses, which points to a dictionary of /// key substitutionValues pairs mapping to other address codes, such as { [email protected] => { 'DisplayName' => 'Mr Foo' } }
return void

AddTo() public method

Add to the 'To' address.
public AddTo ( IEnumerable addresses ) : void
addresses IEnumerable list of email addresses as strings
return void

AddTo() public method

Add to the 'To' address.
public AddTo ( string address ) : void
address string single string eg. '[email protected]'
return void

AddUniqueIdentifiers() public method

This adds parameters and values that will be passed back through SendGrid's Event API if an event notification is triggered by this email.
public AddUniqueIdentifiers ( string>.IDictionary identifiers ) : void
identifiers string>.IDictionary parameter substitutionValues pairs to be passed back on event notification
return void

CreateMimeMessage() public method

Used by the Transport object to create a MIME for SMTP
public CreateMimeMessage ( ) : MailMessage
return SendGrid.Net.Mail.MailMessage

DisableBcc() public method

Disable Bcc app
public DisableBcc ( ) : void
return void

DisableBypassListManagement() public method

Disable the Bypass List Management app
public DisableBypassListManagement ( ) : void
return void

DisableClickTracking() public method

Disable the click tracking app
public DisableClickTracking ( ) : void
return void

DisableFooter() public method

Disable the footer app
public DisableFooter ( ) : void
return void

DisableGoogleAnalytics() public method

Disable the Google Analytics app
public DisableGoogleAnalytics ( ) : void
return void

DisableGravatar() public method

Disable the gravatar app
public DisableGravatar ( ) : void
return void

DisableOpenTracking() public method

Disable the open tracking app
public DisableOpenTracking ( ) : void
return void

DisableSpamCheck() public method

Disable the spam check
public DisableSpamCheck ( ) : void
return void

DisableTemplate() public method

Disable the templates app
public DisableTemplate ( ) : void
return void

DisableUnsubscribe() public method

Disable the unsubscribe app
public DisableUnsubscribe ( ) : void
return void

EnableBcc() public method

Automatically sends a blind carbon copy to an address for every e-mail sent, without adding that address to the header.
public EnableBcc ( string email ) : void
email string A single email recipient
return void

EnableBypassListManagement() public method

Enabing this app will bypass the normal unsubscribe / bounce / spam report checks and queue the e-mail for delivery.
public EnableBypassListManagement ( ) : void
return void

EnableClickTracking() public method

Causes all links to be overwritten, shortened, and pointed to SendGrid's servers so clicks will be tracked.
public EnableClickTracking ( bool includePlainText = false ) : void
includePlainText bool true if links found in plain text portions of the message are to be overwritten
return void

EnableFooter() public method

Attaches a message at the footer of the email
public EnableFooter ( string text = null, string html = null ) : void
text string Message for the plain text body of the email
html string Message for the HTML body of the email
return void

EnableGoogleAnalytics() public method

Re-writes links to integrate with Google Analytics
public EnableGoogleAnalytics ( string source, string medium, string term, string content = null, string campaign = null ) : void
source string Name of the referrer source (e.g. Google, SomeDomain.com, NewsletterA)
medium string Name of the marketing medium (e.g. Email)
term string Identify paid keywords
content string Use to differentiate ads
campaign string Name of the campaign
return void

EnableGravatar() public method

Inserts the gravatar image of the sender to the bottom of the message
public EnableGravatar ( ) : void
return void

EnableOpenTracking() public method

Adds an invisible image to the end of the email which can track e-mail opens.
public EnableOpenTracking ( ) : void
return void

EnableSpamCheck() public method

Provides notification when emails are detected that exceed a predefined spam threshold.
public EnableSpamCheck ( int score = 5, string url = null ) : void
score int Emails with a SpamAssassin score over this substitutionValues will be considered spam and not be delivered.
url string SendGrid will send an HTTP POST request to this url when a message is detected as spam
return void

EnableTemplate() public method

Wraps an HTML template around your email content.
public EnableTemplate ( string html ) : void
html string HTML that your emails will be wrapped in, containing a body replacementTag.
return void

EnableUnsubscribe() public method

Allows SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
public EnableUnsubscribe ( string replace ) : void
replace string Tag in the message body to be replaced with the unsubscribe link and message
return void

EnableUnsubscribe() public method

Allows SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
public EnableUnsubscribe ( string text, string html ) : void
text string string for the plain text email body showing what you want the message to look like.
html string string for the HTML email body showing what you want the message to look like.
return void

GetInstance() public static method

Creates an instance of SendGrid's custom message object
public static GetInstance ( ) : Mail
return Mail

GetInstance() public static method

Creates an instance of SendGrid's custom message object with mail parameters
public static GetInstance ( MailAddress from, MailAddress to, MailAddress cc, MailAddress bcc, string subject, string html, string text ) : Mail
from SendGrid.Net.Mail.MailAddress The email address of the sender
to SendGrid.Net.Mail.MailAddress An array of the recipients
cc SendGrid.Net.Mail.MailAddress Supported over SMTP, with future plans for support in the Web transport
bcc SendGrid.Net.Mail.MailAddress Blind recipients
subject string The subject of the message
html string the html content for the message
text string the plain text part of the message
return Mail

GetRecipients() public method

GetRecipients returns a list of all the recipients by retrieving the to, cc, and bcc lists.
public GetRecipients ( ) : IEnumerable
return IEnumerable

SetCategories() public method

public SetCategories ( IEnumerable categories ) : void
categories IEnumerable
return void

SetCategory() public method

This sets the category for this email. Statistics are stored on a per category basis, so this can be useful for tracking on a per group basis.
public SetCategory ( string category ) : void
category string categories applied to the message
return void