-
Notifications
You must be signed in to change notification settings - Fork 0
NSG.Library.EMail
The namespace contains a class for emailing via SMTP or SendGrid or Mailgun (Mailgun is untested). This requires an ILogger. NSG.Library.Logger has the default. Also needs NSG.Library.Helpers for reading the appSettings. Finally, it needs the following appSettings (see the tests):
- Email:Enabled
- Email:TestEmailName
- Email:UseService
- Email:ApiKey
- Email:MailgunDomain
A fluent interface for smtp mail message
Example:
new EMail( from, to, "Subject", "Body").Send();
This is an implementation of ILogging. Errors are loggged to the ILogger during the sending of email.
From email address
To email address
Email subject line
Email body Instantiate the SMTP MailMessage class using the four parameters.
For example: This sample shows how to call this constructor.
IEMail _mail = new EMail("testfrom@example.com", "testto@example.com", "Sending email is Fun", "This is a test email.").Send();
IEMail to allow fluent design.
This injects an implementation of ILogging from NSG.Library.Logger
From email address
To email address
Email subject line
Email body Instantiate the SMTP MailMessage class using the four parameters.
For example: This sample shows how to call this constructor.
IEMail _mail = new EMail(Log.Logger, "testfrom@example.com", "testto@example.com", "Sending email is Fun", "This is a test email.").Send();
IEMail to allow fluent design.
Instantiate the SMTP MailMessage class using no parameters.
For example: This sample shows how to call this constructor.
MailAddress _from = new MailAddress("testfrom@example.com", "Example From User"); MailAddress _to = new MailAddress("testto@example.com", "Example To User"); string _subject = "Sending email is fun"; string _text = "This is a test email."; IEMail _mail = new EMail().From(_from).To(_to).Subject(_subject).Body(_text).Send();
IEMail to allow fluent design.
This injects an implementation of ILogging from NSG.Library.Logger Instantiate the SMTP MailMessage class using one parameter of logging.
For example: This sample shows how to call this constructor.
MailAddress _from = new MailAddress("testfrom@example.com", "Example From User"); MailAddress _to = new MailAddress("testto@example.com", "Example To User"); string _subject = "Sending email is fun"; string _text = "This is a test email."; IEMail _mail = new EMail(Log.Logger).From(_from).To(_to).Subject(_subject).Body(_text).Send();
IEMail to allow fluent design.
the from email address
the from email address
the subject line
the message body Given and EMail instance, start a new email message by instantiating a new SMTP MailMessage class without parameters.
return its self
Given and EMail instance, start a new email message by instantiating a new SMTP MailMessage class without parameters.
return its self
string of an email address Set the single from address
itself, IEMail to allow fluent design.
string of an email address
display name of the email address Set the single from email address
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Set the single from email address
itself, IEMail to allow fluent design.
an email address Add a To email address.
return its self
an email address
display name of the email address Add a to email address.
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Add a to email address.
itself, IEMail to allow fluent design.
an email address Add a carbon copy (cc) email address.
return its self
an email address
display name of the email address Add a carbon copy (cc) email address.
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Add a carbon copy (cc) email address.
itself, IEMail to allow fluent design.
an email address Add a blind carbon copy (bcc) email address.
return its self
an email address
display name of the email address Add a blind carbon copy (bcc) email address.
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Add a blind carbon copy (bcc) email address.
itself, IEMail to allow fluent design.
the subject line Set the title of email message.
return its self
Email body Set the body of the email message.
return its self
true ot false, is body Html Is the mail message body Html
itself, IEMail to allow fluent design.
byte buffer containing the attachment
name placed on the attachment
mime type like 'application/pdf' Add an attachment to the mail message. For example: This sample shows how to call this constructor.
IEMail _mail = new EMail("testfrom@example.com", "testto@example.com", "Sending email is Fun", "This is a test email.") .Attachment(_textBuffer, _textFile, _textMimeType).Send();
return its self
Use appropriate EMail to send out the message/attachments. After sending clean-up the attachments and the streams and finally the mail-message.
return its self
Use MMPA.Library.EMailing to send out the message/attachments. After sending clean-up the attachments and the streams and finally the mail-message.
return its self
Get the current MailMessage
the current MailMessage
Count of last log records to return return the last few log messages...
list of strings
Output the list of string of the last max emails sent
list of strings
Naturally and automatically dispose of mail-message resource.
Format a string of the current mail message
formated string of a mail message
SMTP MailAddress Format and SMTP MailAddress structure to a string
string like Phil Huhn PHuhn@yahoo.com
Write the current email to a list of string
Property to override the default MailGun URL.
Translate from MailMessage to MultipartFormDataContent.
MultipartFormDataContent (see unit test)
The MailGun api key.
Your domain defined with MailGun. Send the email and any attachments, via the MailGun async task. Note: this was not tested (did not have an account).
itself, IEMail to allow fluent design.
a MailAddress email address lambda method to move MailAddress email address to a new SendGrid EmailAddress address.
a new SendGrid EmailAddress address
a SendGrid EmailAddress email address lambda method to move SendGrid EmailAddress email address to a new MS SMTP MailAddress address.
a new MS SMTP MailAddress address
Translate from MailMessage to SendGridMessage.
a new SendGrid SendGridMessage message found in SendGrid.Helpers.Mail
a SendGridMessage mail message from SendGrid.Helpers.Mail Convert a SendGridMessage mail message, and load it into a new message. For example: This sample shows how to call the NewMailMessage method.
// translate the message from json string of SendGrid message type JavaScriptSerializer j = new JavaScriptSerializer(); SendGridMessage _sgm = (SendGridMessage)j.Deserialize(_jsonString, typeof(SendGridMessage)); IEMail _email = new EMail(Log.Logger).NewMailMessage(_sgm).Send();
itself, IEMail to allow fluent design.
The SendGrid api key Send the email and any attachments, via the SendGrid async task.
itself, IEMail to allow fluent design.
Send the email and any attachments, via the SMTP.
itself, IEMail to allow fluent design.
Send the email and any attachments, via the SMTP async task. After sending clean-up the attachments and the streams and finally the mail-message.
itself, IEMail to allow fluent design.
The namespace contains a class for emailing via SMTP or SendGrid or Mailgun (Mailgun is untested). This requires an ILogger. NSG.Library.Logger has the default. Also needs NSG.Library.Helpers for reading the appSettings. Finally, it needs the following appSettings (see the tests):
- production,
- Email:Enabled
- Email:TestEmailName,
- Email:UseService,
- Email:ApiKey,
- Email:MailgunDomain.
From email address
To email address
Email subject line
Email body Instantiate the SMTP MailMessage class using the four parameters.
IEMail to allow fluent design.
Instantiate the SMTP MailMessage class without parameters.
IEMail to allow fluent design.
a SendGridMessage mail message Load a SendGridMessage mail message into this message For example: This sample shows how to call the NewMailMessage method.
// translate the message from json string of SendGrid message type JavaScriptSerializer j = new JavaScriptSerializer(); SendGridMessage _sgm = (SendGridMessage)j.Deserialize(_jsonString, typeof(SendGridMessage)); IEMail _email = new EMail(Log.Logger).NewMailMessage(_sgm).Send();
IEMail to allow fluent design.
Get the current MailMessage
the current MailMessage
an email address Set the single from email address
itself, IEMail to allow fluent design.
an email address
display name of the email address Set the single from email address
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Set the single from email address
itself, IEMail to allow fluent design.
an email address Add a to email address.
itself, IEMail to allow fluent design.
an email address
display name of the email address Add a to email address.
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Add a to email address.
itself, IEMail to allow fluent design.
an email address Add a carbon copy (cc) email address
itself, IEMail to allow fluent design.
an email address
display name of the email address Add a carbon copy (cc) email address
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Add a carbon copy (cc) email address
itself, IEMail to allow fluent design.
an email address Add a blind carbon copy (bcc) email address
itself, IEMail to allow fluent design.
an email address
display name of the email address Add a blind carbon copy (bcc) email address
itself, IEMail to allow fluent design.
A MailAddress, including an email address and the name Add a blind carbon copy (bcc) email address
itself, IEMail to allow fluent design.
Email subject line Set the email subject line
itself, IEMail to allow fluent design.
Email body Set the email body/text.
itself, IEMail to allow fluent design.
true ot false, is body Html Is the mail message body Html
itself, IEMail to allow fluent design.
byte array of the file to attach
file name of the attachment
mime type of the attachment Set an email attachment.
itself, IEMail to allow fluent design.
Send the email and any attachments, via the means defined in the appSetting:
- Email:UseService.
itself, IEMail to allow fluent design.
Use MMPA.Library.EMailing to send out the message/attachments. After sending clean-up the attachments and the streams and finally the mail-message.
return its self
Send the email and any attachments, via the SMTP.
itself, IEMail to allow fluent design.
Send the email and any attachments, via the SMTP async task.
itself, IEMail to allow fluent design.
Translate from MailMessage to SendGridMessage.
SendGridMessage
The SendGrid api key Send the email and any attachments, via the SendGrid async task.
itself, IEMail to allow fluent design.
Property to override the default MailGun URL.
Translate from MailMessage to MultipartFormDataContent.
MultipartFormDataContent (see unit test)
The MailGun api key.
Your domain defined with MailGun. Send the email and any attachments, via the MailGun async task.
Note: this was not tested (did not have an account).
itself, IEMail to allow fluent design.
Count of last log records to return retrurn the last few log messages...
list of strings Remarks: Output from ILogger
Output a list of string of the last # of emails sent
list of strings