Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class Constants
- {
- public static class Mail
- {
- public const string HOST = "zimbra.smartit.bg";
- public const int PORT = 25;
- public const bool USE_SSL = false;
- public const string USERNAME = "";
- public const string PASSWORD = "";
- public const string FROM = "developers@easycredit.bg";
- }
- }
- public static class Mail
- {
- public static void SendMail(string subject, string body, string mailTo)
- {
- SmtpClient smpt = new SmtpClient(Constants.Mail.HOST, Constants.Mail.PORT);
- smpt.DeliveryMethod = SmtpDeliveryMethod.Network;
- if (!string.IsNullOrEmpty(Constants.Mail.USERNAME) && !string.IsNullOrEmpty(Constants.Mail.PASSWORD))
- {
- smpt.UseDefaultCredentials = false;
- smpt.Credentials = new NetworkCredential(Constants.Mail.USERNAME, Constants.Mail.PASSWORD);
- }
- smpt.EnableSsl = Constants.Mail.USE_SSL;
- MailMessage msg = new MailMessage(Constants.Mail.FROM, mailTo, subject, body);
- msg.IsBodyHtml = true;
- using (smpt)
- {
- smpt.Send(msg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement