using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Mail; namespace SendGridMail { /// /// Represents the basic set of functions that will be called by the user /// includes basic message data manipulation and filter settings /// public interface ISendGrid { #region Properties MailAddress From { get; set; } MailAddress[] To { get; set; } MailAddress[] Cc { get; } MailAddress[] Bcc { get; } MailAddress[] ReplyTo { get; set; } Dictionary StreamedAttachments { get; set; } String[] Attachments { get; set; } String Subject { get; set; } Dictionary Headers { get; set; } IHeader Header { get; set; } String Html { get; set; } String Text { get; set; } #endregion #region Interface for ITransport /// /// Used by the Transport object to create a MIME for SMTP /// /// MIME to be sent MailMessage CreateMimeMessage(); #endregion #region Methods for setting data /// /// Add to the 'To' address. /// /// single string eg. 'you@company.com' void AddTo(String address); /// /// Add to the 'To' address. /// /// list of email addresses as strings void AddTo(IEnumerable addresses); /// /// Add to the 'To' address. /// /// the dictionary keys are the email addresses, which points to a dictionary of /// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } } void AddTo(IDictionary> addresssInfo); /// /// Add to the 'CC' address. /// /// a single email address eg "you@company.com" void AddCc(String address); /// /// Add to the 'CC' address. /// /// a list of email addresses as strings void AddCc(IEnumerable addresses); /// /// Add to the 'CC' address. /// /// the dictionary keys are the email addresses, which points to a dictionary of /// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } } void AddCc(IDictionary> addresssInfo); /// /// Add to the 'Bcc' address. /// /// a single email as the input eg "you@company.com" void AddBcc(String address); /// /// Add to the 'Bcc' address. /// /// a list of emails as an array of strings. void AddBcc(IEnumerable addresses); /// /// Add to the 'Bcc' address. /// /// the dictionary keys are the email addresses, which points to a dictionary of /// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } } void AddBcc(IDictionary> addresssInfo); /// /// 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. /// /// the string in the email that you'll replace eg. '-name-' /// a list of values that will be substituted in for the replacementTag, one for each recipient void AddSubVal(String replacementTag, List substitutionValues); /// /// This adds parameters and values that will be bassed back through SendGrid's /// Event API if an event notification is triggered by this email. /// /// parameter substitutionValues pairs to be passed back on event notification void AddUniqueIdentifiers(IDictionary identifiers); /// /// 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. /// /// categories applied to the message void SetCategory(String category); /// /// Add an attachment to the message. /// /// a fully qualified file path as a string void AddAttachment(String filePath); /// /// Add a stream as an attachment to the message /// /// Stream of file to be attached /// Name of file to be attached void AddAttachment(Stream stream, String name); /// /// GetRecipients returns a list of all the recepients by retrieving the to, cc, and bcc lists. /// /// IEnumerable GetRecipients(); /// /// Add custom headers to the message /// /// key substitutionValues pairs void AddHeaders(IDictionary headers); #endregion #region SMTP API Functions /// /// Disable the gravatar app /// void DisableGravatar(); /// /// Disable the open tracking app /// void DisableOpenTracking(); /// /// Disable the click tracking app /// void DisableClickTracking(); /// /// Disable the spam check /// void DisableSpamCheck(); /// /// Disable the unsubscribe app /// void DisableUnsubscribe(); /// /// Disable the footer app /// void DisableFooter(); /// /// Disable the Google Analytics app /// void DisableGoogleAnalytics(); /// /// Disable the templates app /// void DisableTemplate(); /// /// Disable Bcc app /// void DisableBcc(); /// /// Disable the Bypass List Management app /// void DisableBypassListManagement(); /// /// Inserts the gravatar image of the sender to the bottom of the message /// void EnableGravatar(); /// /// Adds an invisible image to the end of the email which can track e-mail opens. /// void EnableOpenTracking(); /// /// Causes all links to be overwritten, shortened, and pointed to SendGrid's servers so clicks will be tracked. /// /// true if links found in plain text portions of the message are to be overwritten void EnableClickTracking(bool includePlainText = false); /// /// Provides notification when emails are deteched that exceed a predefined spam threshold. /// /// Emails with a SpamAssassin score over this substitutionValues will be considered spam and not be delivered. /// SendGrid will send an HTTP POST request to this url when a message is detected as spam void EnableSpamCheck(int score = 5, String url = null); /// /// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender /// /// String for the plain text email body showing what you want the message to look like. /// String for the HTML email body showing what you want the message to look like. void EnableUnsubscribe(String text, String html); /// /// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender /// /// Tag in the message body to be replaced with the unsubscribe link and message void EnableUnsubscribe(String replace); /// /// Attaches a message at the footer of the email /// /// Message for the plain text body of the email /// Message for the HTML body of the email void EnableFooter(String text = null, String html = null); /// /// Re-writes links to integrate with Google Analytics /// /// Name of the referrer source (e.g. Google, SomeDomain.com, NewsletterA) /// Name of the marketing medium (e.g. Email) /// Identify paid keywords /// Use to differentiate ads /// Name of the campaign void EnableGoogleAnalytics(String source, String medium, String term, String content = null, String campaign = null); /// /// Wraps an HTML template around your email content. /// /// HTML that your emails will be wrapped in, containing a body replacementTag. void EnableTemplate(String html = null); /// /// Automatically sends a blind carbon copy to an address for every e-mail sent, without /// adding that address to the header. /// /// A single email recipient void EnableBcc(String email = null); /// /// Enabing this app will bypass the normal unsubscribe / bounce / spam report checks /// and queue the e-mail for delivery. /// void EnableBypassListManagement(); #endregion } }