Created
May 18, 2013 08:14
A small wrapper class to send emails - Used as a sample as a hard to test implementation(we cannot replace the SmtpClient itself)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Implementation of the mail sender service. | |
/// </summary> | |
public class MailSenderService | |
{ | |
/// <summary> | |
/// Sends the mail using the specified options. | |
/// </summary> | |
/// <param name="mail">The mail.</param> | |
/// <param name="mailOptions">The mail options.</param> | |
public void SendMail(Mail mail, MailOptions mailOptions) | |
{ | |
SmtpClient client = new SmtpClient(); | |
if (mailOptions.SaveToFile) | |
{ | |
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; | |
client.PickupDirectoryLocation = mailOptions.FilePath; | |
} | |
client.Send(mail.GetMailMessage()); | |
Trace.TraceInformation("Send mail successfully with subject : '{0}' from '{1}'.".FormatWith(mail.Subject, mail.FromAddress.Address)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment