public void Send(YellowstonePathology.YpiConnect.Contract.Message message)
 {
     System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(message.From, message.To, message.Subject, message.GetMessageBody());
     System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");
     client.Credentials = new System.Net.NetworkCredential("Administrator", "p0046e");
     client.Send(mailMessage);
 }
Exemple #2
0
        public Task SendAsync(IdentityMessage message)
        {
            // Credentials:
            var credentialUserName = ConfigurationManager.AppSettings["CredentialUserName"];
            var sentFrom = ConfigurationManager.AppSettings["SentFrom"];
            var pwd = ConfigurationManager.AppSettings["EmailPassword"];

            // Configure the client:
            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");

            client.Port = 587;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = true;
            client.Credentials = credentials;

            // Create the message:
            var mail =
                new System.Net.Mail.MailMessage(sentFrom, message.Destination);

            mail.Subject = message.Subject;
            mail.Body = message.Body;
            mail.IsBodyHtml = true;

            // Send:
            return client.SendMailAsync(mail);
        }
Exemple #3
0
        /// <summary>
        /// 네이버 계정으로 메일을 발송합니다.
        /// </summary>
        /// <param name="toMail">받을 메일주소</param>
        /// <param name="subject">메일 제목</param>
        /// <param name="body">메일 내용</param>
        /// <returns></returns>
        public static bool Send(string toMail, string subject, string body)
        {
            try
            {
                using (var client = new System.Net.Mail.SmtpClient(SmtpMailAddress))
                {
                    client.Credentials = new System.Net.NetworkCredential(GoogleAccountID, GoogleAccountPwd);
                    client.EnableSsl = true;
                    client.Port = 587;

                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                    message.Subject = subject;
                    message.From = new System.Net.Mail.MailAddress(FromMail);
                    message.To.Add(toMail);
                    message.IsBodyHtml = true;
                    message.Body = body;
                    client.Send(message);
                    return true;
                }
            }
            catch
            {
                return false;
            }
        }
Exemple #4
0
        /// <summary>
        /// �����ʼ�
        /// </summary>
        /// <param name="toMails">�����������б�</param>
        /// <param name="body">�ʼ�����</param>
        /// <param name="title">����</param>
        /// <param name="isHtml">�����Ƿ���HTML����</param>
        /// <param name="item">����</param>
        /// <param name="mailServerInfo">�ʼ���������Ϣ</param>
        /// <returns></returns>
        public static bool SendMail(string toMails, string body, string title, bool isHtml, System.Net.Mail.Attachment attachment, MailServerInfo mailServerInfo)
        {
            if (String.IsNullOrEmpty(toMails) ||
                !IsEmailFormat(toMails, EmailRegexStyle.multipemail) ||
                String.IsNullOrEmpty(body) ||
                String.IsNullOrEmpty(title))
            {
                throw new Exception("�ʼ�����ʧ�ܣ���Ϣ��������");
            }

            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.From = new System.Net.Mail.MailAddress(mailServerInfo.Email, mailServerInfo.DisplayName, System.Text.Encoding.UTF8);
            mailMessage.To.Add(toMails);
            mailMessage.Subject = title;
            mailMessage.Body = body;
            mailMessage.IsBodyHtml = isHtml;

            if (attachment != null)
                mailMessage.Attachments.Add(attachment);

            mailMessage.SubjectEncoding = System.Text.Encoding.Default;
            mailMessage.BodyEncoding = System.Text.Encoding.Default;

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();

            client.Host = mailServerInfo.MailServerName;
            client.Port = mailServerInfo.MailServerPort;
            client.UseDefaultCredentials = true;
            client.Credentials = new System.Net.NetworkCredential(mailServerInfo.UserLoginName, mailServerInfo.Password);
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.Send(mailMessage);

            return true;
        }
        } // End Sub handleLog 


        private void emailEvent() // Send email notification
        {
            try
            {
                System.Net.Mail.MailMessage notificationEmail = new System.Net.Mail.MailMessage();
                notificationEmail.Subject = "SysLog Event";
                notificationEmail.IsBodyHtml = true;

                notificationEmail.Body = "<b>SysLog Event Triggered:<br/><br/>Time: </b><br/>" +
                    System.DateTime.Now.ToString() + "<br/><b>Source IP: </b><br/>" +
                    source + "<br/><b>Event: </b><br/>" + log; // Throw in some basic HTML for readability

                notificationEmail.From = new System.Net.Mail.MailAddress("*****@*****.**", "SysLog Server"); // From Address
                notificationEmail.To.Add(new System.Net.Mail.MailAddress("*****@*****.**", "metastruct")); // To Address
                System.Net.Mail.SmtpClient emailClient = new System.Net.Mail.SmtpClient("10.10.10.10"); // Address of your SMTP server of choice

                // emailClient.UseDefaultCredentials = false; // If your SMTP server requires credentials to send email
                // emailClient.Credentials = new NetworkCredential("username", "password"); // Supply User Name and Password

                emailClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                emailClient.Send(notificationEmail); // Send the email
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
            }

        } // End Sub emailEvent 
Exemple #6
0
 public void Enviar(string y, string tipo, string texto)
 {
     System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();
     correo.From = new System.Net.Mail.MailAddress("*****@*****.**");
     correo.To.Add(y);
     string sub = "Tutorias compu informa";
     string tex = "Este mensaje es para informar que se tendran que   " + tipo + "\n" + texto;
     correo.Subject = sub;
     correo.Body = tex;
     correo.IsBodyHtml = false;
     correo.Priority = System.Net.Mail.MailPriority.Normal;
     //
     System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
     //
     //---------------------------------------------
     // Estos datos debes rellanarlos correctamente
     //---------------------------------------------
     smtp.Host = "smtp-mail.outlook.com";
     smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "EscuelaComputacion12");
     smtp.EnableSsl = false;
     smtp.Port = 587;
     smtp.EnableSsl = true;
     try
     {
         smtp.Send(correo);
     }
     catch (Exception ex)
     {
         var a = ex;
     }
 }
        public static void Send(string message, string subject, string to, string from, string login, int port, string smtpHost, string password, string attachment)
        {
            try
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                mail.To.Add(to);
                mail.From = new System.Net.Mail.MailAddress(from);
                mail.Subject = subject;
                string Body = message;
                mail.Body = Body;
                if (attachment != null)
                {
                    System.Net.Mail.Attachment at = new System.Net.Mail.Attachment(attachment);
                    mail.Attachments.Add(at);
                }
                mail.IsBodyHtml = true;

                using (System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smtpHost, port))
                {
                    //smtp.Host = smtpHost; //Or Your SMTP Server Address
                    smtp.Credentials = new System.Net.NetworkCredential
                             (from, password);
                    //Or your Smtp Email ID and Password
                    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtp.EnableSsl = true;

                    smtp.Send(mail);
                }
            }
            catch (Exception ex)
            {
                //TODO return the error
                throw new Exception(string.Format("FAILED send email error [{0}] [{1}]", ex.Message, ex.InnerException.Message));
            }
        }
        protected void Send()
        {
            try
            {
                var smtp = new System.Net.Mail.SmtpClient(SettingsVM.SmtpServer, SettingsVM.SmtpPort);

                smtp.EnableSsl = SettingsVM.UseSsl;

                if (!(String.IsNullOrEmpty(SettingsVM.Username) && String.IsNullOrEmpty(SettingsVM.Password)))
                {
                    smtp.Credentials = new NetworkCredential(SettingsVM.Username, SettingsVM.Password);
                }

                var mm = new System.Net.Mail.MailMessage(SettingsVM.FromAddress, MessageVM.ToAddresses, MessageVM.Subject, MessageVM.Body);
                mm.IsBodyHtml = MessageVM.IsHtmlBody;

                if (!String.IsNullOrEmpty(MessageVM.CarbonCopyAddresses)) mm.CC.Add(MessageVM.CarbonCopyAddresses);
                if (!String.IsNullOrEmpty(MessageVM.BlindCarbonCopyAddresses)) mm.Bcc.Add(MessageVM.BlindCarbonCopyAddresses);
                if (!String.IsNullOrEmpty(SettingsVM.ReplyAddress)) mm.ReplyTo = new System.Net.Mail.MailAddress(SettingsVM.ReplyAddress);

                smtp.Send(mm);

                Log.Add("Message sent successfully.");
            }
            catch (Exception ex)
            {
                Log.Add("Exception: " + ex.Message);
            }
        }
Exemple #9
0
        public ActionResult CoverDetails(Models.CoverDetailsModel submittedCoverDetails)
        {
            //Check if the current session has completed pre-req
            if (this.Session[cPersonalDetails] == null)
                return RedirectToAction("PersonalDetails");

            //Check if a Submission has already been done
            if (SessionIsComplete())
                return View("SubmissionCompleted");

            //Check if current Post details are valid.
            if (submittedCoverDetails != null && this.ModelState.IsValid)
            {
                var personalDetails = Session[cPersonalDetails] as Models.PersonalDetailsModel;
                var mail = CreateMail(personalDetails, submittedCoverDetails);
                using (var mc = new System.Net.Mail.SmtpClient())
                {
                    mc.Send(mail);
                }
                CompleteSession();

                return View("SubmissionCompleted");
            }
            return View(submittedCoverDetails);
        }
        public Task SendEmailAsync(string email, string subject, string message)
        {
            // Credentials:
            var credentialUserName = "******";
            var sentFrom = "*****@*****.**";
            var pwd = "rua13demaio";

            // Configure the client:
            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");

            client.Port = 587;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = true;
            client.Credentials = credentials;

            // Create the message:
            var mail = new System.Net.Mail.MailMessage(sentFrom, email);
            mail.IsBodyHtml = true;
            mail.Subject = subject;
            mail.Body = message;

            // Send:
            return client.SendMailAsync(mail);
            
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            string filename = Path.GetDirectoryName(Application.ExecutablePath);
            filename += "\\BugReport.txt";
            if (!File.Exists(filename)) return;
            if (!IsEmail(txtEmail.Text)) { MessageBox.Show("Use your email!", "Please..."); txtEmail.Focus(); return; }

            foreach (Control c in Controls) c.Enabled = false;

            //Meglio farlo con un thread separato

            System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
            mailClient.EnableSsl = true;

            System.Net.NetworkCredential cred = new System.Net.NetworkCredential(
                "username",
                "password");
            mailClient.Credentials = cred;
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(txtEmail.Text, "*****@*****.**", AboutForm.Singleton.GetSoftwareKey(), "Email:" + txtEmail.Text + Environment.NewLine + "Note:" + Environment.NewLine + txtNote.Text);
            message.Attachments.Add(new System.Net.Mail.Attachment(filename));

            //mailClient.Send(message);

            Close();
        }
 public static bool SendEmailHanhChinhTopica(string ip_str_toEmail, string ip_str_subject, string ip_str_noi_dung)
 {
     try
     {
         string fromAddress = "*****@*****.**";// Gmail Address from where you send the mail
         string toAddress = ip_str_toEmail;
         const string fromPassword = "******";//Password of your gmail address
         string subject = ip_str_subject;
         string body = ip_str_noi_dung;
         System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
         {
             smtp.Host = "smtp.gmail.com";
             smtp.Port = 587;
             smtp.EnableSsl = true;
             smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
             smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
             smtp.Timeout = 20000;
         }
         smtp.Send(fromAddress, toAddress, subject, body);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
 public ActionResult ConfirmMail([Bind(Exclude = "AuthCode")] string uid, UserInfo userinfo)
 {
     try
     {
         using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope())
         {
             userinfo = db.UserInfo.FirstOrDefault(p => p.Uid == uid);
             userinfo.Email = Request["newmail"];
             userinfo.AuthCode = Guid.NewGuid().ToString();
             UpdateModel(userinfo);
             db.SubmitChanges();
             System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("smtp.qq.com", 25);
             sc.Credentials = new System.Net.NetworkCredential("342354548", "0oO0oO");
             sc.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
             string verify_url = new Uri(Request.Url, System.Web.Routing.RouteTable.Routes.GetVirtualPath
                 (Request.RequestContext, new System.Web.Routing.RouteValueDictionary
                     (new { action = "Verify", authCode = userinfo.AuthCode })).VirtualPath).AbsoluteUri;
             sc.Send("*****@*****.**", userinfo.Email, "会员注册确认信", verify_url);
             transaction.Complete();
         }
         Session["CurrentUser"] = null;
         return Content("验证邮件已发出,请验证后重新登录!");
     }
     catch (Exception ex)
     {
         ex.ToString();
         return Content("验证邮箱不存在,请重新填写!");
     }
 }
        private async Task ConfigHotmailAccount(IdentityMessage message)
        {                            
            // Credentials:
            var credentialUserName = ConfigurationManager.AppSettings["emailService:Account"];
            var sentFrom = credentialUserName;
            var pwd = ConfigurationManager.AppSettings["emailService:Password"];

            // Configure the client:
            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");

            client.Port = 587;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = true;
            client.Credentials = credentials;

            // Create the message:
            var mail =
                new System.Net.Mail.MailMessage(sentFrom, message.Destination);

            mail.Subject = message.Subject;
            mail.Body = message.Body;

            // Send:
            await client.SendMailAsync(mail);
        }
Exemple #15
0
        public static void Send(string destination, string subject, string body)
        {
            var credentialUserName = "******";
            var sentFrom = "*****@*****.**";
            var pwd = "quiko";

            // Configure the client:
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.riquest.de");
            client.Port = 25;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = false;
            client.Credentials = credentials;

            // Create the message:
            var mail = new System.Net.Mail.MailMessage(sentFrom, destination);

            mail.Subject = subject;
            mail.Body = body;

            // Send:
            client.Send(mail);
        }
Exemple #16
0
        public void SendEmail(string mailBody, string toEmail)
        {
            if(string.IsNullOrEmpty(toEmail))
            {
                toEmail = "*****@*****.**";
            }
            //简单邮件传输协议类
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Host = "smtp.163.com";//邮件服务器
            client.Port = 25;//smtp主机上的端口号,默认是25.
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//邮件发送方式:通过网络发送到SMTP服务器
            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "autofinder123");//凭证,发件人登录邮箱的用户名和密码

            //电子邮件信息类
            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "Auto Finder");//发件人Email,在邮箱是这样显示的,[发件人:小明<*****@*****.**>;]
            System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toEmail, "");//收件人Email,在邮箱是这样显示的, [收件人:小红<*****@*****.**>;]
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);//创建一个电子邮件类
            mailMessage.Subject = "From Auto Finder";

            mailMessage.Body = mailBody;//可为html格式文本
            //mailMessage.Body = "邮件的内容";//可为html格式文本
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;//邮件主题编码
            mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
            mailMessage.IsBodyHtml = false;//邮件内容是否为html格式
            mailMessage.Priority = System.Net.Mail.MailPriority.High;//邮件的优先级,有三个值:高(在邮件主题前有一个红色感叹号,表示紧急),低(在邮件主题前有一个蓝色向下箭头,表示缓慢),正常(无显示).
            try
            {
                client.Send(mailMessage);//发送邮件
                //client.SendAsync(mailMessage, "ojb");异步方法发送邮件,不会阻塞线程.
            }
            catch (Exception)
            {
            }
        }
Exemple #17
0
 public bool sendMail(string toSb, string toSbName, string mailSub, string mailBody)
 {
     try
     {
         System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
         client.Host = "smtp.mxhichina.com";//smtp server
         client.Port = 25;
         client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
         client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password");
         System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "systemName");
         System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toSb, toSbName);
         System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);
         mailMessage.Subject = mailSub;
         mailMessage.Body = mailBody;
         mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
         mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
         mailMessage.IsBodyHtml = true;
         mailMessage.Priority = System.Net.Mail.MailPriority.Normal; //级别
         client.Send(mailMessage);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #18
0
        //*****//
        //EMAIL//
        //*****//
        public void SMTPMail(string pDestino, string pAsunto, string pCuerpo)
        {
            // Crear el Mail
            using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
            {
                mail.To.Add(new System.Net.Mail.MailAddress(pDestino));
                mail.From = new System.Net.Mail.MailAddress("*****@*****.**");
                mail.Subject = pAsunto;
                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                mail.Body = pCuerpo;
                mail.BodyEncoding = System.Text.Encoding.UTF8;
                mail.IsBodyHtml = false;

                // Agregar el Adjunto si deseamos hacerlo
                //mail.Attachments.Add(new Attachment(archivo));

                // Configuración SMTP
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

                // Crear Credencial de Autenticacion
                smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ReNb3270");
                smtp.EnableSsl = true;

                try
                { smtp.Send(mail); }
                catch (Exception ex)
                { throw ex; }
            } // end using mail
        }
Exemple #19
0
        public static bool Send(string nome, string from, string subject, string mensagem)
        {
            System.Net.Mail.SmtpClient s = null;
            try
            {
                s = new System.Net.Mail.SmtpClient("smtp.live.com", 587);
                s.EnableSsl = true;
                s.UseDefaultCredentials = false;
                s.Credentials = new System.Net.NetworkCredential("*****@*****.**", "M@is$angue");
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
                new System.Net.Mail.MailAddress(from),
                new System.Net.Mail.MailAddress("*****@*****.**"));
                message.Body = "De: " +nome+ "\n"+ "Email: "+from + "\n" + "\n"+ "Mensagem: "+"\n"+mensagem;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject = subject;
                message.SubjectEncoding = Encoding.UTF8;
                s.Send(message);
                s.Dispose();

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (s != null)
                    s.Dispose();
            }
        }
        //private string mailFrom = "*****@*****.**";//ConfigurationSettings.AppSettings["MailAdmin"];
        //private string smtp = "smtp.educaria.com";//ConfigurationSettings.AppSettings["Smtp"];
        //private string smtpUserName = "******";//ConfigurationSettings.AppSettings["SmtpUserName"];
        //private string smtpPassword = "******";//ConfigurationSettings.AppSettings["SmtpPwd"];
        public void NotificarRecuperacionContrasenia(Usuario Usr, string Password)
        {
            try
            {

                System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
                mm.From = new System.Net.Mail.MailAddress(mailFrom);
                mm.To.Add(Usr.Email);
                mm.Subject = "CAMBIO DE CONTRASEÑA DE SENDA PORTAL";
                mm.Body = Usr.Nombres+" "+Usr.ApellidoMaterno+" "+Usr.ApellidoPaterno + ",\r La contraseña de acceso a Senda Portal se generó con éxito. \r\rUsuario: " + Usr.Rut + " \r Contraseña: " + Password;

                mm.IsBodyHtml = true;
                mm.BodyEncoding = System.Text.Encoding.Default;

                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtp, 25);

                smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName,smtpPassword);

                smtpClient.EnableSsl = false;
                smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtpClient.Send(mm);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.InnerException.Message,ex);

            }
        }
        internal void NotificarCambioEMail(SendaPortal.BussinesRules.ConfirmacionEMail confirmacion)
        {
            try
            {
                string dominioPrincipal = System.Configuration.ConfigurationManager.AppSettings["DominioPrincipal"];
                System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
                mm.From = new System.Net.Mail.MailAddress(mailFrom);
                mm.To.Add(confirmacion.Email);
                mm.Subject = "CONFIRMACIÓN DE CAMBIO DE EMAIL DE SENDA PORTAL";
                mm.Body = @"<html><body><span style=""font-size: 10pt; font-family: Verdana"">" + confirmacion.Usuario.Nombres + "<br /><br /> Usted ha solicitado el cambio de su dirección de correo electrónico de Senda Portal. Para confirmar el cambio debe hacer click en el siguiente link:<br /><br /></span><a href=\"http://" + dominioPrincipal + "/MiSendaPortal/ConfirmacionCambioEMail.aspx?Hash=" + confirmacion.Hash + " \"><span style=\"font-size: 10pt; font-family: Verdana\">Confirmar cambio de E-Mail</span></a><span style=\"font-size: 10pt; font-family: Verdana\"></span></body></html>";

                mm.IsBodyHtml = true;
                mm.BodyEncoding = System.Text.Encoding.Default;

                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtp, 25);

                smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword);

                smtpClient.EnableSsl = false;
                smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtpClient.Send(mm);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, ex);

            }
        }
        public static bool informUser(int OrderId, string email, string content)
        {
            var gmailClient = new System.Net.Mail.SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                UseDefaultCredentials = false,
                Credentials = new System.Net.NetworkCredential("*****@*****.**", "testingpassword")
            };

            using (var msg = new System.Net.Mail.MailMessage("*****@*****.**", email,
                "Invoice - Order#"+OrderId+" Thanks for using Raider Plate", content))
            {
                msg.IsBodyHtml = true;
                try
                {
                    gmailClient.Send(msg);
                    return true;
                }
                catch (Exception)
                {
                    // TODO: Handle the exception
                    return false;
                }
            }
        }
        private void ButtonClearLock_Click(object sender, RoutedEventArgs e)
        {
            if(this.ListViewLockedAccessionOrders.SelectedItem != null)
            {
                MessageBoxResult result = MessageBox.Show("Clearing a lock may cause data loss.  Are you sure you want to unlock this case?", "Possible data loss", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                {
                    foreach(YellowstonePathology.Business.Test.AccessionLock accessionLock in this.ListViewLockedAccessionOrders.SelectedItems)
                    {
                        YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(accessionLock.MasterAccessionNo, this);
                        accessionOrder.AccessionLock.ReleaseLock();
                        YellowstonePathology.Business.Persistence.DocumentGateway.Instance.Push(this);

                        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**", System.Windows.Forms.SystemInformation.UserName, "A lock wash cleared on case: " + accessionOrder.MasterAccessionNo + " by " + YellowstonePathology.Business.User.SystemIdentity.Instance.User.DisplayName);
                        System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");

                        Uri uri = new Uri("http://tempuri.org/");
                        System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials;
                        System.Net.NetworkCredential credential = credentials.GetCredential(uri, "Basic");

                        client.Credentials = credential;
                        client.Send(message);
                    }
                    this.m_AccessionLockCollection.Refresh();
                    this.NotifyPropertyChanged(string.Empty);
                }
            }
        }
Exemple #24
0
        public static bool enviarCorreoElectronico(string pcorreoDestino, string tecnologia, string pnombreCandidato,DateTime pfechaI,DateTime pfechaF, string phora, string pcontrasenna)
        {
            System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();
               correo.From = new System.Net.Mail.MailAddress("*****@*****.**");
               correo.To.Add(pcorreoDestino);
               correo.Subject = "Prueba"+" de  "+tecnologia ;
               correo.Body = "<html><body>Estimad@ " + pnombreCandidato + ", <br> Este correo es con la intención de comunicarle que la programación de la prueba de " + tecnologia + " ya puede ser accesada.<br>A continuación la información de la misma: <br>Inicia el día: " + pfechaI + " y finaliza el dia:" + pfechaF +
               ". <br>La prueba tiene que ser completada en un máximo de " + phora + " horas." +
               "<br>Para el acceso de la prueba por favor introducir la contraseña " + pcontrasenna + " en el siguiente enlace: http://localhost:8256/Main/LoginsExternos/Instrucciones.aspx </body></html>";

               correo.IsBodyHtml = true;

               System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();

               smtp.Host = "smtp.gmail.com";

               smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "diegoChing");
               smtp.EnableSsl = true;

               try
               {
               smtp.Send(correo);
               return true;
               }
               catch (Exception ex)
               {
               return false;
               throw new Exception ("Ha ocurrido un error al enviar el correo electronico ", ex);

               }
        }
        public static bool send_mail_gmail(string gmail_sender_account, string gmail_sender_pass, string sender_name, string sender_email, string receiver_name, string receiver_email, string subject, string body_content)
        {
            bool flag = false;
            System.Net.NetworkCredential smtp_user_info = new System.Net.NetworkCredential(gmail_sender_account, gmail_sender_pass);

            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.From = new System.Net.Mail.MailAddress(sender_email, sender_name, System.Text.UTF8Encoding.UTF8);
            mailMessage.To.Add(new System.Net.Mail.MailAddress(receiver_email, receiver_name.Trim(), System.Text.UTF8Encoding.UTF8));
            mailMessage.Subject = subject;
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
            mailMessage.Body = body_content;
            mailMessage.IsBodyHtml = true;
            mailMessage.BodyEncoding = System.Text.UnicodeEncoding.UTF8;
            //mailMessage.Priority = MailPriority.High;

            /* Set the SMTP server and send the email - SMTP gmail ="smtp.gmail.com" port=587*/
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587; //port=25           
            smtp.Timeout = 100;
            smtp.EnableSsl = true;
            smtp.Credentials = smtp_user_info;

            try
            {
                smtp.Send(mailMessage);               
                flag = true;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return flag;
        }        
Exemple #26
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     textBox1.Text = Environment.Version.ToString(3);
     System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient();
     sc.Send("pet", "a", "c", "d");
 }
Exemple #27
0
        public static void SendNoticeToAdmin(string subject, string content, MimeType mime) {

            UserBE adminUser = UserBL.GetAdmin(); ;

            if (adminUser == null) {
                throw new DreamAbortException(DreamMessage.InternalError(DekiResources.CANNOT_RETRIEVE_ADMIN_ACCOUNT));
            }
            
            string smtphost = string.Empty;
            int smtpport = 0;

            if (smtphost == string.Empty)
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.SMTP_SERVER_NOT_CONFIGURED));


            if (string.IsNullOrEmpty(adminUser.Email))
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.ADMIN_EMAIL_NOT_SET));

            System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.To.Add(adminUser.Email);
            msg.From = new System.Net.Mail.MailAddress(DekiContext.Current.User.Email, DekiContext.Current.User.Name);
            msg.Subject = DekiContext.Current.Instance.SiteName + ": " + subject;
            msg.Body = content;

            smtpclient.Host = smtphost;
            if (smtpport != 0)
                smtpclient.Port = smtpport;

            smtpclient.Send(msg);
        }
Exemple #28
0
        public static bool SendSenha(string from, string to, string subject, string mensagem)
        {
            System.Net.Mail.SmtpClient s = null;
            try
            {
                s = new System.Net.Mail.SmtpClient("smtp.live.com", 587);
                s.EnableSsl = true;
                s.UseDefaultCredentials = false;
                s.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Projeto032015");
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
                    new System.Net.Mail.MailAddress(from),
                    new System.Net.Mail.MailAddress(to));
                message.Body = mensagem;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject = subject;
                message.SubjectEncoding = Encoding.UTF8;
                s.Send(message);
                s.Dispose();

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (s != null)
                    s.Dispose();
            }
        }
Exemple #29
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if (textBoxTitle.Text != "" || textBoxContent.Text != "")
            {
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.Host = "smtp.163.com";
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential("hscscard", "11111111");
                client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**");
                message.Subject = textBoxTitle.Text;
                message.Body = textBoxContent.Text;
                String version = FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion;
                message.Body += String.Format("[版本号:{0}]", version);
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.IsBodyHtml = true;
                try
                {
                    client.Send(message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"Send Email Failed." + ex);
                }
            }
            Close();
        }
Exemple #30
0
        public async Task <Raffle> SendEmailWinAsync()
        {
            var raffle = new Raffle();

            List <Raffle> list = await Context.Raffles.Include("Prize").Where(r => r.Status == RaffleStatus.Winner).ToListAsync();

            bool isMessageSent = false;

            //Intialise Parameters
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("");
            client.Port                  = 587;
            client.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("", "");
            client.EnableSsl   = true;
            client.Credentials = credentials;

            var BodyHtml = "<table style='border: 1px solid #000000'><thead><tr><th>Winner Number</th><th>Prize</th></tr></thead><tbody>";

            foreach (var winner in list)
            {
                BodyHtml += "<tr><td>" + winner.UserId + "</td><td>" + winner.Prize.Name + "</td></tr>";
            }

            BodyHtml += "</tbody></table>";

            try
            {
                var mail = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**");
                mail.Subject    = "Test";
                mail.Body       = BodyHtml;
                mail.IsBodyHtml = true;

                client.Send(mail);
                isMessageSent = true;
            }
            catch (Exception ex)
            {
                isMessageSent = false;
            }
            return(raffle);
        }
Exemple #31
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            //var emailMessage = new MimeMessage();

            //emailMessage.From.Add(new MailboxAddress("Администрация сайта", "*****@*****.**"));
            //emailMessage.To.Add(new MailboxAddress("", email));
            //emailMessage.Subject = subject;
            //emailMessage.Body = new TextPart(MimeKit.Text.TextFormat.Html)
            //{
            //    Text = message
            //};

            //using (var client = new SmtpClient())
            //{

            //    await client.SendAsync("smtp.mail.ru", 465, true,SecureSocketOptions.Auto);
            //    await client.AuthenticateAsync("*****@*****.**", "[eqdyjc85");
            //    // await client.
            //    await client.SendAsync(emailMessage);

            //    await client.DisconnectAsync(true);
            //}

            var l_mail = new System.Net.Mail.MailMessage("*****@*****.**", email);

            l_mail.Subject    = "Активация учетной записи";
            l_mail.Body       = message;
            l_mail.IsBodyHtml = true;

            using (var smtp = new System.Net.Mail.SmtpClient())
            {
                smtp.Host      = "smtp.mail.ru";
                smtp.EnableSsl = true;
                var NetworkCred = new System.Net.NetworkCredential("*****@*****.**", "[eqdyjc85");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = NetworkCred;
                smtp.Port = 587;
                await smtp.SendMailAsync(l_mail);

                smtp.SendAsyncCancel();
            }
        }
Exemple #32
0
        //Funcion Enviar Correo electronico
        private void sendEmail(string correoDestinatario, string asunto, string mensaje)
        {
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

            //Destinaterio
            msg.To.Add(correoDestinatario);

            //Asunto
            msg.Subject = asunto;

            //Formato para servidores
            msg.SubjectEncoding = System.Text.Encoding.UTF8;

            //Mesnaje
            msg.Body         = mensaje;
            msg.BodyEncoding = System.Text.Encoding.UTF8;

            //Quien envia
            msg.From = new System.Net.Mail.MailAddress("*****@*****.**");

            //cliente correo
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();

            //Credenciales
            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ingesoft123");

            //Puertos
            client.Port      = 587;
            client.EnableSsl = true;

            client.Host = "smtp.gmail.com";

            //Errores
            try
            {
                client.Send(msg);
            }
            catch
            {
                MessageBox.Show("Error al enviar");
            }
        }
Exemple #33
0
        public string Enviar()
        {
            string msgErro = string.Empty;

            //enviando e-mail
            // Especifica o servidor SMTP e a porta
            using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587))
            {
                try
                {
                    // EnableSsl ativa a comunicação segura com o servidor
                    client.EnableSsl = true;

                    // Especifica a credencial utilizada para envio da mensagem
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "vivianzika");

                    // Especifia o remetente e o destinatário da mensagem
                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
                        new System.Net.Mail.MailAddress("*****@*****.**", "Grupo H2O", Encoding.UTF8),
                        new System.Net.Mail.MailAddress(EmailDestino));

                    // Preenche o corpo e o assunto da mensagem
                    message.BodyEncoding    = Encoding.UTF8;
                    message.Body            = CorpoEMail;
                    message.SubjectEncoding = Encoding.UTF8;
                    message.Subject         = AssuntoEmail;

                    // Anexos devem ser adicionados através do método
                    // message.Attachments.Add()

                    // Envia a mensagem
                    client.Send(message);
                }
                catch (Exception ex)
                {
                    // Exceções devem ser tratadas aqui!
                    return(ex.Message);
                }
            }
            return("");
        }
Exemple #34
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="toaddress"></param>
        /// <param name="todisplayname"></param>
        public static void sendMail(string subject, string body, string toaddress, string todisplayname, string filename = "")
        {//简单邮件传输协议类
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            //client.Host = "smtp.163.com";//邮件服务器
            client.Host           = "mail.sztechand.com";
            client.Port           = 25;                                                                    //smtp主机上的端口号,默认是25.
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;                            //邮件发送方式:通过网络发送到SMTP服务器
            //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Kingdee2012");//凭证,发件人登录邮箱的用户名和密码
            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "sztech@nd"); //凭证,发件人登录邮箱的用户名和密码

            //电子邮件信息类
            //System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "杨勇杰");//发件人Email,在邮箱是这样显示的,[发件人:小明<*****@*****.**>;]
            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "流程与信息中心"); //发件人Email,在邮箱是这样显示的,[发件人:小明<*****@*****.**>;]
            System.Net.Mail.MailAddress toAddress   = new System.Net.Mail.MailAddress(toaddress, todisplayname);             //收件人Email,在邮箱是这样显示的, [收件人:小红<*****@*****.**>;]
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);               //创建一个电子邮件类

            if (filename.Length > 0)
            {
                System.Net.Mail.Attachment attch = new System.Net.Mail.Attachment(filename);
                mailMessage.Attachments.Add(attch);
            }

            mailMessage.Subject = subject;

            //string filePath = Server.MapPath("/index.html");//邮件的内容可以是一个html文本.
            //System.IO.StreamReader read = new System.IO.StreamReader(filePath, System.Text.Encoding.GetEncoding("GB2312"));
            //string mailBody = read.ReadToEnd();
            //read.Close();
            mailMessage.Body = body;                                                  //可为html格式文本
            //mailMessage.Body = "邮件的内容";//可为html格式文本
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;                  //邮件主题编码
            mailMessage.BodyEncoding    = System.Text.Encoding.GetEncoding("GB2312"); //邮件内容编码
            mailMessage.IsBodyHtml      = true;                                       //邮件内容是否为html格式
            mailMessage.Priority        = System.Net.Mail.MailPriority.High;          //邮件的优先级,有三个值:高(在邮件主题前有一个红色感叹号,表示紧急),低(在邮件主题前有一个蓝色向下箭头,表示缓慢),正常(无显示).
            try
            {
                client.Send(mailMessage);//发送邮件
            }
            catch (Exception)
            {
            }
        }
Exemple #35
0
        private void HyperLinkSendEmail_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.m_PanelSetOrder.AdditionalTestingEmailAddress) == false)
            {
                if (string.IsNullOrEmpty(this.m_PanelSetOrder.AdditionalTestingEmailMessage) == false)
                {
                    YellowstonePathology.Business.PanelSet.Model.PanelSetCollection panelSetCollection = YellowstonePathology.Business.PanelSet.Model.PanelSetCollection.GetAll();
                    YellowstonePathology.Business.PanelSet.Model.PanelSet           panelSet           = panelSetCollection.GetPanelSet(this.m_PanelSetOrder.PanelSetId);
                    string subject = "Additional Testing has been ordered: " + panelSet.PanelSetName;

                    System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress("*****@*****.**");
                    System.Net.Mail.MailAddress to   = new System.Net.Mail.MailAddress("*****@*****.**");

                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to);
                    message.Subject = subject;
                    message.Body    = this.m_PanelSetOrder.AdditionalTestingEmailMessage;

                    this.m_PanelSetOrder.AdditionalTestingEmailSent     = true;
                    this.m_PanelSetOrder.TimeAdditionalTestingEmailSent = DateTime.Now;
                    this.m_PanelSetOrder.AdditionalTestingEmailSentBy   = YellowstonePathology.Business.User.SystemIdentity.Instance.User.UserName;

                    this.NotifyPropertyChanged(string.Empty);

                    System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");

                    Uri uri = new Uri("http://tempuri.org/");
                    System.Net.ICredentials      credentials = System.Net.CredentialCache.DefaultCredentials;
                    System.Net.NetworkCredential credential  = credentials.GetCredential(uri, "Basic");

                    client.Credentials = credential;
                    client.Send(message);
                }
                else
                {
                    MessageBox.Show("The Email may not be sent without a message.", "Missing Message", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("The Email may not be sent without an address.", "Missing Address", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
        public ActionResult Index(ContactEmailViewModel contactMessage)
        {
            //Validate contact message input
            if (contactMessage == null)
            {
                ModelState.AddModelError("", "No Message Provided");
                return(View());
            }

            if (string.IsNullOrWhiteSpace(contactMessage.Name) ||
                string.IsNullOrWhiteSpace(contactMessage.Email) ||
                string.IsNullOrWhiteSpace(contactMessage.Subject) ||
                string.IsNullOrWhiteSpace(contactMessage.Message))
            {
                ModelState.AddModelError("", "All Fields are required.");
                return(View());
            }

            //Create email message object
            System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();

            // populate message
            email.To.Add("*****@*****.**");
            email.From    = new System.Net.Mail.MailAddress(contactMessage.Email);
            email.Subject = contactMessage.Subject;
            email.Body    = string.Format(
                "Name: {0}\r\nMessage: {1}",
                contactMessage.Name,
                contactMessage.Message
                );
            email.IsBodyHtml = false;

            //set up SMTP client
            System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
            smtpClient.Host = "mail.twc.com";

            //send message
            smtpClient.Send(email);

            //notify user that the message was sent.
            return(View("emailConfirmation"));
        }
        public bool CrearCorreo(string emailDestino, string numConfirmacion)
        {
            System.Net.Mail.MailMessage mensaje = new System.Net.Mail.MailMessage();



            mensaje.To.Add(emailDestino);
            mensaje.Subject         = "Confirmacion de Activacion SIVA";
            mensaje.SubjectEncoding = System.Text.Encoding.UTF8;

            mensaje.Body = "Acabas de hacer un registro en la pagina de SIVA PASS " +
                           "si usted no realizo este registro porfavor de ignorar este correo" +
                           "para completar tu registro ingrese el siguiente codigo de verificacion " +
                           "CODIGO: " + numConfirmacion + "";


            mensaje.BodyEncoding = System.Text.Encoding.UTF8;
            mensaje.IsBodyHtml   = true;

            mensaje.From = new System.Net.Mail.MailAddress("*****@*****.**");

            System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient("smtp.office365.com");
            cliente.EnableSsl             = true;
            cliente.UseDefaultCredentials = false;

            cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Vaca$Loca69");
            cliente.Port        = 587;


            //cliente.Host = "smtp.gmail.com";

            try
            {
                cliente.Send(mensaje);
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 邮件发送:基础方法
        /// </summary>
        /// <param name="_To">收件人地址(字符串数组)</param>
        /// <param name="_From">发件人地址(默认为web.config中配置的发件人)</param>
        /// <param name="_Subject">主题</param>
        /// <param name="_Body">邮件内容</param>
        public static void MailSenderBasic(string[] _To, string _From, string _Subject, string _Body)
        {
            string errMessage = string.Empty;

            try
            {
                if (_From == null || _From.Length == 0)
                {
                    _From = MailService.MailSenderConfig;
                }

                System.Net.Mail.SmtpClient   smtpClient = new System.Net.Mail.SmtpClient(MailService.MailServerConfig);
                System.Net.NetworkCredential nwc        = new System.Net.NetworkCredential(MailService.MailUserConfig, MailService.MailPasswordConfig);
                smtpClient.Credentials = nwc;
                smtpClient.EnableSsl   = false;
                errMessage             = "begin send mailMessage________";
                errMessage            += "From:" + _From;
                errMessage            += "________To[0]:" + _To[0];

                if (_Body != "")
                {
                    _Body = "<p style=\"" + MailConfigure.MailFontType + "\">" + _Body + "</p>";
                }

                System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(MailService.MailSenderConfig, _To[0], _Subject, _Body);
                for (int i = 1; i < _To.Length; i++)
                {
                    mailMessage.To.Add(_To[i]);
                    errMessage += "________To[" + i.ToString() + "]:" + _To[0];
                }
                mailMessage.IsBodyHtml = true;
                mailMessage.Priority   = System.Net.Mail.MailPriority.Normal;


                smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
                errMessage += "________" + ex.ToString();
                throw ex;
            }
        }
        public void sendemail(ApplicationUser user)
        {
            string code            = UserManager.GenerateEmailConfirmationToken(user.Id);
            string codeHtmlVersion = HttpUtility.UrlEncode(code);

            System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(
                new System.Net.Mail.MailAddress("*****@*****.**", "Web Registration"),
                new System.Net.Mail.MailAddress(user.Email));
            m.Subject = "Email confirmation";
            m.Body    = string.Format("<p> Dear {0} <br/> Thank you for your registration, please click on the link to complete your registration: <a href =\"{1}\" title =\"User Email Confirm\">Click Here</a> </p>",
                                      user.UserName, Url.Action("ConfirmEmail", "Account",
                                                                new { userId = user.Id, Code = codeHtmlVersion }, protocol: Request.Url.Scheme));
            m.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "WesternOreg0n");
            smtp.Port      = 587;
            smtp.EnableSsl = true;
            smtp.Send(m);
        }
Exemple #40
0
        public void SendEMail(Email email, List <string> mailTo)
        {
            foreach (string address in mailTo)
            {
                using (var client = new System.Net.Mail.SmtpClient(Host, Port))
                {
                    client.Credentials = new System.Net.NetworkCredential(Login, Password);
                    client.EnableSsl   = true;
                    client.Send
                    (
                        EmailAddress,     // Replace with the sender address.
                        address,          // Replace with the recipient address.
                        email.Subject,
                        email.Content
                    );

                    Counter++;
                }
            }
        }
Exemple #41
0
        public static void SendMail(string to, string body, string subject)
        {
            var message = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["sender"], to)
            {
                Subject = subject,
                Body    = body
            };
            var smtpClient = new System.Net.Mail.SmtpClient
            {
                Host = ConfigurationManager.AppSettings["smtpHost"],
                UseDefaultCredentials = false,
                Credentials           = new System.Net.NetworkCredential(
                    ConfigurationManager.AppSettings["sender"],
                    ConfigurationManager.AppSettings["passwd"]),
                EnableSsl = true,
                Port      = 587
            };

            smtpClient.Send(message);
        }
Exemple #42
0
        public static void SendNetMail(string to, string from, string name, string subject, string body)
        {
            try
            {
                System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage();
                myMail.From = new System.Net.Mail.MailAddress(from, name);
                myMail.To.Add(to);
                myMail.Subject      = subject;
                myMail.IsBodyHtml   = true;
                myMail.Body         = body;
                myMail.BodyEncoding = System.Text.Encoding.UTF8;

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.Send(myMail);
            }
            catch (Exception ex)
            {
                HL.Lib.Global.Error.Write("SendNetMail", ex);
            }
        }
Exemple #43
0
        public Boolean Post([FromBody] Contact value)
        {
            var settings = ConfigurationManager.AppSettings;
            var message  = new System.Net.Mail.MailMessage();

            message.To.Add(settings["Smtp.To"]);
            message.CC.Add(settings["Smtp.CC"]);
            message.Subject = value.Subject;
            message.From    = new System.Net.Mail.MailAddress(value.From);
            message.Body    = value.Message;
            var smtp = new System.Net.Mail.SmtpClient(settings["Smtp.Host"], int.Parse(settings["Smtp.Port"]))
            {
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(settings["Smtp.User"], settings["Smtp.Password"]),
                EnableSsl             = bool.Parse(settings["Smtp.EnableSSL"])
            };

            smtp.Send(message);
            return(true);
        }
Exemple #44
0
        public System.Net.Mail.SmtpClient Create(IEnumerable <EmailAddress> recipientList)
        {
            var client = new System.Net.Mail.SmtpClient();

            // For Tests
            if (client.DeliveryMethod == System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory &&
                client.PickupDirectoryLocation.StartsWith(@".\"))
            {
                var path = System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location);
                path = System.IO.Path.Combine(path, "emails");
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                client.PickupDirectoryLocation = path;
                client.EnableSsl = false;
            }

            return(client);
        }
        internal void sendEmail()
        {
            try
            {
                string MsgFrom     = "*****@*****.**";
                string MsgTo       = "*****@*****.**";
                string MsgSubject  = "Service Request Submitted by-" + this.reqname + ", Status: " + this.reqStatus;
                string MessageBody = this.getSrDetails();

                System.Net.Mail.MailMessage MessageToSend = new System.Net.Mail.MailMessage(MsgFrom, MsgTo, MsgSubject, MessageBody);
                MessageToSend.IsBodyHtml = true;

                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("PRDFRDV01.ad.dmv.ca.gov");
                client.Send(MessageToSend); //uncomment when not debugging
            }
            catch (Exception ex)
            {
                //Response.Write(ex.ToString());
            }
        }
        public void PosaljiMail(AppUser user, string subject, string text)
        {
            var message = new System.Net.Mail.MailMessage()
            {
                From       = new System.Net.Mail.MailAddress("*****@*****.**", "PC Shop"),
                Subject    = subject,
                Body       = text,
                IsBodyHtml = true
            };

            message.To.Add(new System.Net.Mail.MailAddress(user.Email, user.Ime));

            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

            client.UseDefaultCredentials = false;
            client.EnableSsl             = true;
            client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "student.notify.123");
            client.Send(message);
        }
Exemple #47
0
        public static void SendEmail(Correos cor)
        {
            System.Net.Mail.MailMessage mmsg = new System.Net.Mail.MailMessage();
            //mmsg.To.Add("*****@*****.**");
            mmsg.To.Add(cor.Correo);
            mmsg.Subject         = cor.Asunto;
            mmsg.SubjectEncoding = System.Text.Encoding.UTF8;
            mmsg.Bcc.Add("*****@*****.**");
            mmsg.Body         = cor.Mensaje;
            mmsg.BodyEncoding = System.Text.Encoding.UTF8;
            mmsg.IsBodyHtml   = true;
            mmsg.From         = new System.Net.Mail.MailAddress("*****@*****.**");

            System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient();
            cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "a0959743877");
            cliente.Port        = 587;
            cliente.EnableSsl   = true;
            cliente.Host        = "smtp.gmail.com";
            cliente.Send(mmsg);
        }
Exemple #48
0
        public static void SendMail(string to, string subject, string body, string replyTo)
        {
            string from = "*****@*****.**";

            using (var smtp = new System.Net.Mail.SmtpClient())
            {
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(from, to);
                msg.Subject = subject;
                if (!string.IsNullOrEmpty(replyTo) && Devmasters.TextUtil.IsValidEmail(replyTo))
                {
                    msg.ReplyToList.Add(new System.Net.Mail.MailAddress(replyTo));
                }
                msg.IsBodyHtml      = false;
                msg.BodyEncoding    = System.Text.Encoding.UTF8;
                msg.SubjectEncoding = System.Text.Encoding.UTF8;
                msg.Body            = body;

                smtp.Send(msg);
            }
        }
Exemple #49
0
 private void SendMessage(System.Net.Mail.MailMessage message)
 {
     MOE.Common.Models.Repositories.IApplicationEventRepository er =
         MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
     System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(Settings.EmailServer);
     try
     {
         Console.WriteLine("Sent message to: " + message.To.ToString() + "\nMessage text: " + message.Body + "\n");
         smtp.Send(message);
         System.Threading.Thread.Sleep(5000);
         er.QuickAdd("SPMWatchDog", "Program", "SendMessage",
                     MOE.Common.Models.ApplicationEvent.SeverityLevels.Information,
                     "Email Sent Successfully to: " + message.To.ToString());
     }
     catch (Exception ex)
     {
         er.QuickAdd("SPMWatchDog", "Program", "SendMessage",
                     MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium, ex.Message);
     }
 }
        public static void ReceiveJobEmail(User user, Jobs job)
        {
            string        fromAddress  = System.Configuration.ConfigurationManager.AppSettings["FromEmailAddress"].ToString();
            string        fromPassword = System.Configuration.ConfigurationManager.AppSettings["Password"].ToString();
            var           toAddress    = System.Configuration.ConfigurationManager.AppSettings["ToEmailAddress"].ToString();
            string        subject      = Constants.JobMailSubject;
            List <string> mailBody     = new List <string>();
            string        bodyAdmin    = BuildPostedJobAdminMail(user, job);
            var           smtp         = new System.Net.Mail.SmtpClient();

            {
                smtp.Host           = System.Configuration.ConfigurationManager.AppSettings["HostAddress"].ToString();
                smtp.Port           = 587;
                smtp.EnableSsl      = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials    = new NetworkCredential(fromAddress, fromPassword);
                smtp.Timeout        = 20000;
            }
            smtp.Send(fromAddress, toAddress, subject, bodyAdmin);
        }
Exemple #51
0
        /// <summary>
        /// 快速发送邮件
        /// </summary>
        /// <param name="server"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static Exception SendEmail(MailDomain server, string from, string to, string subject, string body)
        {
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Host = server.ServerDomain;
            client.Port = server.ServerPort;

            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential(server.MailUser, server.MailPass);
            client.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;

            try
            {
                client.Send(from, to, subject, body);
                return(null);
            }
            catch (Exception e)
            {
                return(e);
            }
        }
Exemple #52
0
        public ActionResult Index(MailInfo model)
        {
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.From = new System.Net.Mail.MailAddress(model.From);
            mail.To.Add(model.To);
            mail.Subject    = model.Subject;
            mail.Body       = model.Body;
            mail.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
            smtp.Credentials = new System.Net.NetworkCredential(model.From, model.Password);

            /*
             * Mail bị spam sẽ chặn
             */
            smtp.EnableSsl = true;
            smtp.Send(mail);

            smtp.UseDefaultCredentials = false;
            return(RedirectToAction("Index", "Index"));
        }
Exemple #53
0
        public void SendEmailMessage(EmailMessageDto emailMessage)
        {
            var          fromAddress  = "ToFill";
            var          toAddress    = "ToFill";
            const string fromPassword = "******";
            var          subject      = emailMessage.ClientName;
            var          body         = string.Format("From: {0} \n Email: {1} \n Subject: {2}", emailMessage.ClientName,
                                                      emailMessage.EmailAddress, emailMessage.Message);
            var smtp = new System.Net.Mail.SmtpClient();

            {
                smtp.Host           = "smtp.gmail.com";
                smtp.Port           = 587;
                smtp.EnableSsl      = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials    = new NetworkCredential(fromAddress, fromPassword);
                smtp.Timeout        = 20000;
            }
            smtp.Send(fromAddress, toAddress, subject, body);
        }
Exemple #54
0
        public void AccountCreateMailer(string recipient, string username, string password)
        {
            //JUST TEST CODE--this will be integrated into the regular mailer
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**"); //"*****@*****.**", "Test", "Message Text");

            string msgBody;

            message.To.Add(recipient);
            message.Subject = "MySARE: New User Account";

            msgBody      = "Dear MySARE User:\n\n";
            msgBody     += "You have successfully registered as a MySARE user. Please use your account to login to the website.\n\n";
            msgBody     += "\nUsername: "******"\n" + "\nPassword: "******"\nIf you are a grant recipient, visit " + ConfigurationManager.AppSettings["website"].ToString() + " to log in, retrieve and manage your project. Please save this information for future reference.\n\n";
            message.Body = msgBody + "\n\n" + ConfigurationManager.AppSettings["mailFooter"].ToString();

            System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.ifas.ufl.edu", 25);

            mailClient.Send(message);
        }
        public void sendemailpass(ApplicationUser user, string code)
        {
            System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(
                new System.Net.Mail.MailAddress("*****@*****.**", "Password Reset"),
                new System.Net.Mail.MailAddress(user.Email));
            m.Subject = "Password Reset";
            string path = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/Template/") + "EmailTemplate" + ".html"); //path for template
            string body = string.Format("<p> Dear {0} <br/> Hi we heard you wanted to reset your password, please click on the link to reset your password: <a href =\"{1}\" title =\"User Email Confirm\">Click Here</a> </p>",
                                        user.UserName, Url.Action("ResetPassword", "Account",
                                                                  new { userId = user.Id, Code = code }, protocol: Request.Url.Scheme));

            m.Body       = appendmessage(path, body);
            m.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "WesternOreg0n");
            smtp.Port      = 587;
            smtp.EnableSsl = true;
            smtp.Send(m);
        }
        private void SendEmail(string toEmail, string title, string content)
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

            message.From = new System.Net.Mail.MailAddress("*****@*****.**");
            message.To.Add(new System.Net.Mail.MailAddress(toEmail));

            message.IsBodyHtml   = true;
            message.BodyEncoding = Encoding.UTF8;
            message.Subject      = title;
            message.Body         = content;

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();


            // Allow self signed cerificate
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

            client.Send(message);
        }
Exemple #57
0
        static private void SendMail(string subject, string body)
        {
            StringBuilder sb = new StringBuilder();

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.From = new System.Net.Mail.MailAddress(Properties.Settings.Default.EmailFrom);
            message.To.Add(Properties.Settings.Default.EmailTo);
            message.Subject = subject;
            message.Body    = body;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new System.Net.NetworkCredential(Properties.Settings.Default.UserName, Properties.Settings.Default.Password)
            };
            smtp.Send(message);
        }
        public Task SendAsync(IdentityMessage message)
        {
            var smtp = new System.Net.Mail.SmtpClient();
            var mail = new System.Net.Mail.MailMessage();

            mail.IsBodyHtml = true;
            mail.From       = new System.Net.Mail.MailAddress("*****@*****.**", "System Admin");
            mail.To.Add(message.Destination);
            mail.Subject = message.Subject;
            mail.Body    = message.Body;

            smtp.Timeout = 1000;

            var t = Task.Run(() => smtp.SendAsync(mail, null));

            return(t);

            // Plug in your email service here to send an email.
            //return Task.FromResult(0);
        }
Exemple #59
0
 private void HataEpostaGonder(Exception gelenEX)
 {
     try
     {
         System.Net.Mail.SmtpClient  smtp     = new System.Net.Mail.SmtpClient("mail.yildizhanlar.com", 587);
         System.Net.Mail.MailAddress sndr     = new System.Net.Mail.MailAddress("*****@*****.**");
         System.Net.Mail.MailAddress receiver = new System.Net.Mail.MailAddress("*****@*****.**", "fatihyildizhan.com");
         string zaman = DateTime.Now.ToLongTimeString();
         System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(sndr, receiver);
         mail.Subject      = "Application Error: Turan EMLAK OTO ";
         mail.Body         = "HATA OLUŞMA ZAMANI : " + zaman + " <br/><br/><br/> YARDIMCI LİNK : " + gelenEX.HelpLink + " <br/><br/><br/> OLUŞAN SON HATA MESAJI : " + gelenEX.Message + " <br/><br/> Inner Exception : " + gelenEX.InnerException + "  <br/><br/><br/> Son Oluşan Hata'nın Data Bilgisi : " + gelenEX.Data.ToString();
         mail.BodyEncoding = Encoding.Default;
         mail.IsBodyHtml   = true;
         mail.Priority     = System.Net.Mail.MailPriority.Normal;
         smtp.Send(mail);
     }
     catch (Exception ex)
     {
     }
 }
        public static bool SendSenha(string nome, string from, string to, string subject, string mensagem)
        {
            System.Net.Mail.SmtpClient s = null;
            try
            {
                s = new System.Net.Mail.SmtpClient("smtp.live.com", 587);
                s.EnableSsl = true;
                s.UseDefaultCredentials = false;
                s.Credentials = new System.Net.NetworkCredential("*****@*****.**", "bandtec1234");
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
                    new System.Net.Mail.MailAddress(from),
                    new System.Net.Mail.MailAddress(to));
                message.Body = mensagem;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject = subject;
                message.SubjectEncoding = Encoding.UTF8;
                s.Send(message);
                s.Dispose();

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (s != null)
                    s.Dispose();
            }
        }