Exemplo n.º 1
0
        /// <summary>
        /// method to send new password through Email
        /// </summary>
        /// <param name="businessEmail"></param>
        public static void SendMailWithAttachements(BusinessEmail businessEmail)
        {
            try
            {
                using (MailMessage mail = new MailMessage())
                {
                    using (SmtpClient SmtpServer = new SmtpClient(businessEmail.EmailSmtpServerHost))
                    {
                        mail.From = new MailAddress(businessEmail.EmailFrom);
                        mail.To.Add(businessEmail.EmailTo);
                        mail.Subject    = businessEmail.EmailSubject;
                        mail.Body       = businessEmail.EmailBody;
                        mail.IsBodyHtml = true;
                        mail.Priority   = MailPriority.High;
                        foreach (var attachedFiles in businessEmail.AttachementFiles)
                        {
                            Attachment objAttachment = new Attachment(attachedFiles);
                            mail.Attachments.Add(objAttachment);
                        }

                        SmtpServer.Port        = businessEmail.EmailSmtpServerPort;
                        SmtpServer.Credentials = new System.Net.NetworkCredential(businessEmail.EmailSmtpServer, businessEmail.PasswordSmtpServer);
                        SmtpServer.EnableSsl   = businessEmail.EmailSmtpServerSSL;
                        SmtpServer.Send(mail);
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// method to send new password through Email
        /// </summary>
        /// <param name="businessEmail"></param>
        public static void SendMail(BusinessEmail businessEmail)
        {
            try
            {
                using (MailMessage mail = new MailMessage())
                {
                    using (SmtpClient SmtpServer = new SmtpClient(businessEmail.EmailSmtpServerHost))
                    {
                        mail.From = new MailAddress(businessEmail.EmailFrom);
                        mail.To.Add(businessEmail.EmailTo);
                        mail.Subject    = businessEmail.EmailSubject;
                        mail.Body       = businessEmail.EmailBody;
                        mail.IsBodyHtml = true;
                        mail.Priority   = MailPriority.High;

                        SmtpServer.Port        = businessEmail.EmailSmtpServerPort;
                        SmtpServer.Credentials = new System.Net.NetworkCredential(businessEmail.EmailSmtpServer, businessEmail.PasswordSmtpServer);
                        SmtpServer.EnableSsl   = businessEmail.EmailSmtpServerSSL;
                        SmtpServer.Send(mail);
                    }
                }
            }
            catch
            {
                throw;
            }
        }