Пример #1
0
        public static bool SendMailThruGmail(Email email)
        {
            try
            {
                MailAddress fromAddress = new MailAddress(email.mailFrom);
                MailAddress toAddress = new MailAddress(email.mailTo);
                string subject = email.mailSubject;
                string body = email.mailBody;

                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(fromAddress.Address, toAddress.Address, subject, body);
                msg.IsBodyHtml = true;

                var client = new SmtpClient("smtp.gmail.com", 587)
                {
                    Credentials = new NetworkCredential("*****@*****.**", "bains@awan"),
                    EnableSsl = true
                };

                client.Send(msg);
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return false;
            }
        }
Пример #2
0
 public ActionResult Index(string name, string email, string message)
 {
     Email objEmail = new Email();
     objEmail.mailTo = email;
     objEmail.mailBody = message;
     objEmail.mailSubject = "Help";
     objEmail.mailFrom = this.repository.GetUserEmail(_userStatistics.UserId);
     Utilities.SendMailThruGmail(objEmail);
     TempData["IsEmailSent"] = "Mail successfully sent.";
     return View("Index");
 }
Пример #3
0
 public static void SendMailsToQueue(Email[] emails, string queuePath)
 {
     if (emails.Count() != 0)
     {
         var EmailQueue = new MessageQueueSender(queuePath);
         foreach (Email email in emails)
         {
             EmailQueue.SendMessage(email);
         }
     }
 }
Пример #4
0
 private void StartEmailHandler()
 {
     string queuePath = ".\\private$\\EMAILQUEUE";
     Email email = new Email() { mailTo = "*****@*****.**", mailFrom = "*****@*****.**", mailSubject = "QueueMail", mailBody = "Test MAil" };
     //Utilities.SendMailThruGmail(email);
     //Utilities.SendMailToQueue(email, queuePath);
     //var reciver = new QueueListener(queuePath);
     //reciver.Start();
 }
Пример #5
0
        public static void SendMailToQueue(Email email, string queuePath)
        {
            if (email != null)
            {
                var EmailQueue = new MessageQueueSender(queuePath);

                EmailQueue.SendMessage(email);
            }
        }