using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Mail;
namespace SendGridMail
{
///
/// Internal object to represent the way in which email may be sent.
/// The library supports sending through either SMTP or Web interfaces.
///
public enum TransportType
{
SMTP,
REST
};
///
/// 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; }
String[] Attachments { get; set; }
String Subject { get; set; }
Dictionary Headers { get; set; }
IHeader Header { get; set; }
String Html { get; set; }
String Text { get; set; }
TransportType Transport { get; set; }
#endregion
#region Interface for ITransport
///
/// Used by the Transport object to create a MIME for SMTP
///
/// MIME to be sent
MailMessage CreateMimeMessage();
///
/// Creates a new transport object, and sends this message out.
///
/// Sendgrid user credentials
void Mail(NetworkCredential credentials);
#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 value 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 value 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 value pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } }
void AddBcc(IDictionary> addresssInfo);
///
/// Adds a substitution value to be used during the mail merge. Substitutions will happen in the order
/// added, so calls to this should match calls to addTo.
///
/// the string in the email that you'll replace eg. '-name-'
/// a list of values that will be substituted in for the tag, one for each recipient
void AddSubVal(String tag, params String[] value);
///
/// Add an attachment to the message.
///
/// a fully qualified file path as a string
void AddAttachment(String filePath);
///
/// 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 value 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 value 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 tag.
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
}
}