This project is read-only.
Before publishing any release we need to configure the smtp server in email helper. I used gmail smtp server. So, I have to provide one of my email id and password. So, before checking in I changes the password so that my password is not exposed. So, please contact me before making any release.

using System;
using System.Net;
using System.Net.Mail;
using MefBasic.Threading;

namespace MusicAssistant.Helper
{
    public class EMailHelper
    {
        private const string SmtpServer = "smtp.gmail.com";
        private const string SmtpUsername = "UserName;
        private const string Password = "Password";
        private const string ContactEMail = "ContactAddress";

        public static void Send(string from, string subject, string message)
        {
            var worker = new BackgroundWorkerEx();
            worker.DoWork += (s, e) =>
                                 {
                                     try
                                     {
                                         var client = new SmtpClient(SmtpServer, 587)
                                         {
                                             Credentials = new NetworkCredential(SmtpUsername, Password),
                                             EnableSsl = true
                                         };
                                         var mailMessage = new MailMessage(from, ContactEMail, subject, message);
                                         mailMessage.ReplyToList.Add(from);
                                         client.Send(mailMessage);
                                     }
                                     catch (Exception ex)
                                     {
                                         e.Result = ex;
                                     }

                                 };
            worker.RunWorkerBlocked();
            
       }
    }
}

Last edited May 27, 2011 at 5:43 AM by hsmasud, version 1

Comments

No comments yet.