Exemplo n.º 1
1
 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);
 }
Exemplo n.º 2
0
        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;
        }        
Exemplo n.º 3
0
        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;
                }
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
        public System.Net.Mail.MailMessage BuildMessage(IDictionary<string, string> replaceTerms)
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.From = this.From;
            message.Sender = this.Sender;
            message.ReplyTo = this.ReplyTo;

            string subject = this.Subject;
            if (replaceTerms != null && replaceTerms.Count > 0)
                foreach (KeyValuePair<string, string> kvp in replaceTerms)
                    subject = subject.Replace(kvp.Key, kvp.Value);

            message.Subject = subject;
            message.SubjectEncoding = Encoding.UTF8;

            string body = this.Body;
            if (replaceTerms != null && replaceTerms.Count > 0)
                foreach (KeyValuePair<string, string> kvp in replaceTerms)
                    body = body.Replace(kvp.Key, kvp.Value);

            message.Body = body;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml = this.BodyIsHtml;

            return message;
        }
Exemplo n.º 7
0
        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);
                }
            }
        }
Exemplo n.º 8
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;
     }
 }
Exemplo n.º 9
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;
     }
 }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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();
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
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();
            }
        }
Exemplo n.º 15
0
        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 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);
            
        }
Exemplo n.º 17
0
        } // 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 
Exemplo n.º 18
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);
        }
        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));
            }
        }
        public System.Net.Mail.MailMessage CriarEmail(string remetente, string para, string copia, string copiaOculta, string assunto, string mensagem, string anexo)
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

            // Informa o REMETENTE
            message.From = new System.Net.Mail.MailAddress(remetente);

            // Informa o DESTINATARIO
            message.To.Add(para);

            // Verifica se existe COPIA para enviar
            if (!string.IsNullOrEmpty(copia))
                message.CC.Add(copia);

            // Verifica se existe COPIA OCULTA para enviar
            if (!string.IsNullOrEmpty(copiaOculta))
                message.Bcc.Add(copiaOculta);

            // Anexa arquivo escolhido
            message.Attachments.Add(new System.Net.Mail.Attachment(anexo));

            // Informa o ASSUNTO
            message.Subject = assunto;

            // Informa o CORPO
            message.Body = mensagem;

            return message;
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
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)
            {
            }
        }
Exemplo n.º 23
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
        }
Exemplo n.º 24
0
        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);

            }
        }
Exemplo n.º 25
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);

               }
        }
Exemplo n.º 26
0
        //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);

            }
        }
Exemplo n.º 27
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;
            }
        }
Exemplo n.º 28
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            sBody = "Dear "+txtRecipientName.ToString();

            sBody += System.IO.File.ReadAllText(@"c:\users\student\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Email.txt");

            sBody += "\n\n http://localhost:49394//RefLanding.aspx";
            sBody += "\n\nPasscode : yess";

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.To.Add(txtRecipientEmail.Text.ToString());
            message.Subject = "Confidential Personal Enquiry for "+"Applicant Name";
            message.From = new System.Net.Mail.MailAddress("*****@*****.**");
            message.Body = sBody;
            System.Net.Mail.SmtpClient mySmtpClient = new System.Net.Mail.SmtpClient();
            System.Net.NetworkCredential myCredential = new System.Net.NetworkCredential("*****@*****.**", "project9password");
            mySmtpClient.Host = "smtp.gmail.com";  //Have specified the smtp host name
            mySmtpClient.UseDefaultCredentials = false;
            mySmtpClient.Port = 587;
            mySmtpClient.Credentials = myCredential;
            mySmtpClient.EnableSsl = true;
            mySmtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

               // System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("email.usc.edu");
               mySmtpClient.Send(message);
        }
 protected virtual void Run(ClientPipelineArgs args)
 {
     //if (Sitecore.Context.IsAdministrator || allowNonAdminDownload())
     //{
     //    string tempPath = GetFilePath();
     //    SheerResponse.Download(tempPath);
     //}
     //else
     //{
         if (!args.IsPostBack)
         {
             string email = Sitecore.Context.User.Profile.Email;
             SheerResponse.Input("Enter your email address", email);
             args.WaitForPostBack();
         }
         else
         {
             if (args.HasResult)
             {
                 System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                 message.To.Add(args.Result);
                 string tempPath = GetFilePath();
                 message.Attachments.Add(new System.Net.Mail.Attachment(tempPath));
                 message.Subject = string.Format("ASR Report ({0})", Current.Context.ReportItem.Name);
                 message.From = new System.Net.Mail.MailAddress(Current.Context.Settings.EmailFrom);
                 message.Body = "Attached is your report sent at " + DateTime.Now.ToString("dd/MM/yyyy HH:mm");
                 Sitecore.MainUtil.SendMail(message);
             }
         }
     //}
 }
Exemplo n.º 30
0
        public string EnviarEmail(string remitente, string destinatario, string asunto, string cuerpo)
        {
            if (String.IsNullOrEmpty(destinatario))
            {
                return(null);
            }

            if (!destinatario.Contains("@"))
            {
                return(null);
            }

            System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();

            correo.From = new System.Net.Mail.MailAddress(remitente, "UNIVERSIDAD DE CALDAS");
            correo.To.Add(destinatario);
            correo.Subject    = asunto;
            correo.Body       = cuerpo;
            correo.IsBodyHtml = false;
            correo.Priority   = System.Net.Mail.MailPriority.Normal;

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "regacad2012");
            smtp.Port        = 587;
            //smtp.Port = 465;
            smtp.Host      = "smtp.googlemail.com";
            smtp.EnableSsl = true;

            try
            {
                smtp.Send(correo);
                return(null);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 31
0
        public Task SendAsync(IdentityMessage message)
        {
            // Credentials:
            var credentialUserName = ConfigurationManager.AppSettings["emailUsername"];
            var sentFrom           = ConfigurationManager.AppSettings["emailFrom"];
            var pwd = ConfigurationManager.AppSettings["emailPassword"];

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

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

            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp.sendgrid.net");

            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:
            return(client.SendMailAsync(mail));
        }
Exemplo n.º 32
0
        public ActionResult DenemeForm(Wissen.Models.DenemeForm model1)
        {
            if (ModelState.IsValid)
            {
                bool hasError = false;
                try
                {
                    System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
                    mailMessage.From    = new System.Net.Mail.MailAddress("*****@*****.**", "ali");
                    mailMessage.Subject = "İletişim Formu: " + model1.FirstName + "" + model1.LastName;
                    mailMessage.To.Add("[email protected] [email protected]");
                    string body;
                    body  = "Ad Soyad: " + model1.FirstName + "<br />";
                    body += "Telefon: " + model1.LastName + "<br />";
                    body += "E-posta: " + model1.Email + "<br />";
                    body += "Telefon: " + model1.Phone + "<br />";
                    mailMessage.IsBodyHtml = true;
                    mailMessage.Body       = body;

                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
                    smtp.Credentials = new System.Net.NetworkCredential("mail", "şifre");
                    smtp.EnableSsl   = true;
                    smtp.Send(mailMessage);
                    ViewBag.Message = "Mesajınız gönderildi. Teşekkür ederiz.";
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Error", ex.Message);
                    hasError = true;
                }
                if (hasError == false)
                {
                    ViewBag.Message = "Mail başarıyla gönderildi";
                }
                return(View());
            }
            return(View());
        }
Exemplo n.º 33
0
        public ActionResult DenemeForm(WissenMVCProject.Models.DenemeForm model)
        {
            if (ModelState.IsValid)
            {
                bool hasError = false;
                try
                {
                    System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
                    mailMessage.From    = new System.Net.Mail.MailAddress("*****@*****.**", "Wissen");
                    mailMessage.Subject = "İletişim Formu: " + model.FirstName + " " + model.LastName;
                    mailMessage.To.Add("*****@*****.**");

                    string body;
                    body  = "Ad: " + model.FirstName + "<br />";
                    body  = "Soyad: " + model.LastName + "<br />";
                    body += "Telefon: " + model.Phone + "<br />";
                    body += "E-posta: " + model.Email + "<br />";

                    mailMessage.IsBodyHtml = true;
                    mailMessage.Body       = body;

                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "****************");
                    smtp.EnableSsl   = true;
                    smtp.Send(mailMessage);
                }catch (Exception ex)
                {
                    ModelState.AddModelError("Error", ex.Message);
                    hasError = true;
                }
                if (hasError == false)
                {
                    ViewBag.Message = "Mail başarıyla gönderildi.";
                }
                return(View());
            }
            return(View());
        }
Exemplo n.º 34
0
        public IHttpActionResult GetEveryBody(int id)
        {
            ProductOwner po = db.ProductOwner.Find(id);

            if (po == null)
            {
                return(NotFound());
            }

            System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(
                new System.Net.Mail.MailAddress("*****@*****.**", "Web Registration"),
                new System.Net.Mail.MailAddress(po.Email));
            m.Subject = "Email confirmation";
            m.To.Add("*****@*****.**");

            //m.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\"title=\"User Email Confirm\">{1}</a>",
            //po.OwnerName, Url.Link("api/Account/Register",
            //new { Token = po.ID, Email = po.Email }));

            string link = "http://*****:*****@promactinfo.com", "Promact2015");
            //  smtp.EnableSsl = true;

            smtp.Send(m);
            po.Approval        = true;
            po.EmailConfirmed  = false;
            db.Entry(po).State = EntityState.Modified;
            // db.ORequest.Add(ownerrequest);
            db.SaveChanges();

            return(Ok(po));
        }
Exemplo n.º 35
0
        public Task SendAsync(IdentityMessage message)
        {
            try
            {
                // Credentials:
                var credentialUserName = Global.EmailFrom;
                var sentFrom           = Global.EmailSentFrom;
                var pwd = Global.EmailPassword;

                // Configure the client:
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(Global.EmailSmtpClient);

                //client.Port = Global.EmailPort;
                //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));
            }
            catch (Exception ex)
            {
                string errormessage = ex.Message;
                return(Task.FromResult(0));
            }
        }
Exemplo n.º 36
0
        public static void envoieCourriel(string sujet, string message, string destinataire, bool async = false)
        {
            //A changé l'adresse par défaut!!!!
            System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage("*****@*****.**", destinataire /*"*****@*****.**"*/);
            string statut = "";
            string erreur = "";

            email.Subject      = sujet;
            email.IsBodyHtml   = true;
            email.Body         = message;
            email.BodyEncoding = System.Text.Encoding.UTF8;

            System.Net.Mail.SmtpClient mailObj = null;

            try
            {
                mailObj = new System.Net.Mail.SmtpClient();

                mailObj.Credentials = new NetworkCredential("*****@*****.**", "chat4178");
                mailObj.Port        = 587;
                mailObj.Host        = "smtp.gmail.com";
                mailObj.EnableSsl   = true;
            }
            catch (Exception e)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(e);
            }

            try
            {
                mailObj.Send(email);
                //A réussi à envoyé
            }
            catch (Exception e)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(e);
            }
        }
Exemplo n.º 37
0
        //bilgilendirme mesajı gönderme metodu..
        //appSetting email göndermek için webconfige eklenir

        public void SendMail(string konu, string strBody, string kime)
        {
            try
            {
                string mailAdres = ConfigurationManager.AppSettings["EMailAdres"].ToString();
                string mailSifre = ConfigurationManager.AppSettings["Password"].ToString();

                //string Notifications = ConfigurationManager.AppSettings["Notifications"].ToString();
                //if (Notifications == "ON")
                //{
                string ssl = ConfigurationManager.AppSettings["SSL"].ToString();

                System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage(mailAdres, kime, konu, strBody);
                MyMailMessage.IsBodyHtml = true;
                int    MailPortNumber = Convert.ToInt32(ConfigurationManager.AppSettings["MailPortNumber"].ToString()); //587
                string MailURL        = ConfigurationManager.AppSettings["MailURL"].ToString();                         //
                System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential(mailAdres, mailSifre);
                System.Net.Mail.SmtpClient   mailClient         = new System.Net.Mail.SmtpClient(MailURL, MailPortNumber);
                if (ssl == "Enabled")
                {
                    mailClient.EnableSsl = true;
                }
                else if (ssl == "Disabled")
                {
                    mailClient.EnableSsl = false;
                }

                mailClient.UseDefaultCredentials = false;
                mailClient.Credentials           = mailAuthentication;
                mailClient.Send(MyMailMessage);
            }
            catch (Exception)
            {
                AlertCustom.ShowCustom(this.Page, "Kayıt başarılı, şifreniz E-Posta adresinize gönderilmiştir.");
            }

            //}
        }
Exemplo n.º 38
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                //classe MailMessage
                //criando o objeto para enviar mensagem via web
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                //identificando o destinatario
                msg.To.Add(txtPara.Text);
                //pegando o e-mail de que ira enviar dados
                msg.From = new System.Net.Mail.MailAddress(txtDe.Text);
                //pegando o assunto do e-mail
                msg.Subject = txtAssunto.Text;
                //pegando o conteudo do e-mail
                msg.Body = txtMensagem.Text;

                //******************************************************************
                //pegando o caminho
                System.Net.Mail.Attachment anexo = new System.Net.Mail.Attachment(txtAnexo.Text);
                //pegando o anexo da mensagem
                msg.Attachments.Add(anexo);

                //*******************************************************************
                //agora, coloque o SMTP e a prota de deu e-mail
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(recebeSMTP, porta);
                //habilitando a criptografia
                smtp.EnableSsl = true;
                //criando a credencial
                smtp.Credentials = new System.Net.NetworkCredential(txtDe.Text, txtSenha.Text);
                //enviando...
                smtp.Send(msg);
                MessageBox.Show("Mensagem Enviada com Sucesso!!!");
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 39
0
        private void sendMailAsync(System.Net.Mail.MailMessage mailMessage)
        {
            var mimeMessage = MimeKit.MimeMessage.CreateFromMailMessage(mailMessage);

            var gmailMessage = new Google.Apis.Gmail.v1.Data.Message
            {
                Raw = Encode(mimeMessage.ToString())
            };


            UserCredential credential;

            using (var stream =
                       new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
            {
                // The file token.json stores the user's access and refresh tokens, and is created
                // automatically when the authorization flow completes for the first time.
                string credPath = "token.json";
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Gmail API service.
            var service = new GmailService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            Google.Apis.Gmail.v1.UsersResource.MessagesResource.SendRequest request = service.Users.Messages.Send(gmailMessage, "me");

            request.Execute();
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser()
                {
                    Name                 = model.Name,
                    LastName             = model.LastName,
                    Email                = model.Email,
                    UserName             = model.UserName,
                    NumberIdentification = model.NumberIdentification,
                    EmailConfirmed       = false
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // Confirmar correo.
                    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("Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", user.UserName, Url.Action("ConfirmEmail", "Account", new { Token = user.Id, Email = user.Email }, Request.Url.Scheme));
                    m.IsBodyHtml = true;
                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("tesla.cujae.edu.cu");
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Badday16.");
                    smtp.EnableSsl   = false;
                    smtp.Send(m);

                    return(RedirectToAction("Login", "Account"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 41
0
        static void Main(string[] args)
        {
            string SMTPUser     = "******";
            string SMTPPassword = "******";
            int    SmtpPort     = 587;
            string SmtpServer   = "smtp.yandex.com";

            System.Net.Mail.MailAddress sender = new System.Net.Mail.MailAddress("*****@*****.**", "", System.Text.Encoding.UTF8);

            System.Net.Mail.MailAddress recipient = new System.Net.Mail.MailAddress("*****@*****.**", "", System.Text.Encoding.UTF8);

            System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage(sender, recipient);

            email.BodyEncoding    = System.Text.Encoding.UTF8;
            email.SubjectEncoding = System.Text.Encoding.UTF8;

            System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(System.Text.RegularExpressions.Regex.Replace("My plan body", @"<(.|\n)*?>", string.Empty), null, MediaTypeNames.Text.Plain);

            System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("My HTML body", null, MediaTypeNames.Text.Html);

            email.AlternateViews.Clear();
            email.AlternateViews.Add(plainView);
            email.AlternateViews.Add(htmlView);
            email.Subject = $"Azure {DateTime.Now}";

            System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient();
            SMTP.UseDefaultCredentials = false;

            SMTP.Host = SmtpServer;
            SMTP.Port = SmtpPort;

            SMTP.Credentials    = new System.Net.NetworkCredential(SMTPUser, SMTPPassword);
            SMTP.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

            SMTP.EnableSsl = true;

            SMTP.Send(email);
        }
Exemplo n.º 42
0
        public ActionResult SendEmail(UsersListModel model)
        {
            if (string.IsNullOrEmpty(model.EmailTo))
            {
                ModelState.AddModelError(string.Empty, "To is a required field");
                return(RedirectToAction("Index", new { RegionId = model.SelectedRegionId, CountryId = model.SelectedCountryId, AgencyGroupId = model.SelectedAgencyGroupId, AgencyId = model.SelectedAgencyId, errorMsg = "To is a required field" }));
            }
            using (var smtpClient = new System.Net.Mail.SmtpClient())
            {
                //  smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

                //smtpClient = 25;
                try
                {
                    var msg = new System.Net.Mail.MailMessage();
                    smtpClient.Port = 25;
                    msg.IsBodyHtml  = true;
                    msg.Subject     = model.Subject;
                    msg.Body        = model.Body;
                    msg.To.Add(model.EmailTo);
                    if (!string.IsNullOrEmpty(model.EmailBcc))
                    {
                        msg.Bcc.Add(model.EmailBcc);
                    }
                    if (!string.IsNullOrEmpty(model.EmailCc))
                    {
                        msg.CC.Add(model.EmailCc);
                    }
                    smtpClient.Send(msg);
                    return(RedirectToAction("Index", new { RegionId = model.SelectedRegionId, CountryId = model.SelectedCountryId, AgencyGroupId = model.SelectedAgencyGroupId, AgencyId = model.SelectedAgencyId, successMsg = "The email sent successfully" }));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex);
                    return(RedirectToAction("Index", new { RegionId = model.SelectedRegionId, CountryId = model.SelectedCountryId, AgencyGroupId = model.SelectedAgencyGroupId, AgencyId = model.SelectedAgencyId, errorMsg = ex.Message }));
                }
            }
        }
        public void EnviarCorreo(string cuerpoMensaje, string tituloMensaje)
        {
            string listaDestinatarios = ListaCorreosDestinatarios().TrimEnd(',');
            List <ConfigCorreo> listaConfiguracionCorreo = new List <ConfigCorreo>();

            listaConfiguracionCorreo = GetAllConfigCorreo();

            System.Net.Mail.MailMessage mmsg = new System.Net.Mail.MailMessage();
            mmsg.To.Add(listaDestinatarios.ToString());
            mmsg.Subject         = tituloMensaje; //"Correo ejemplo GIA";
            mmsg.SubjectEncoding = System.Text.Encoding.UTF8;
            mmsg.Body            = cuerpoMensaje; //"Prueba de correo GIA";
            mmsg.BodyEncoding    = System.Text.Encoding.UTF8;
            mmsg.IsBodyHtml      = false;
            mmsg.From            = new System.Net.Mail.MailAddress(listaConfiguracionCorreo[0].remitente);

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

            cliente.Host                  = listaConfiguracionCorreo[0].host;
            cliente.Port                  = listaConfiguracionCorreo[0].puerto;
            cliente.EnableSsl             = true;
            cliente.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
            cliente.UseDefaultCredentials = false;
            cliente.Credentials           = new System.Net.NetworkCredential(listaConfiguracionCorreo[0].remitente, listaConfiguracionCorreo[0].password);



            string output = null;

            try
            {
                cliente.Send(mmsg);
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                output = "Error enviando correo electrónico: " + ex.Message;
            }
        }
        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";
            string path = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/Template/") + "EmailTemplate" + ".html");  //path for template
            string 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)); //message

            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);
        }
Exemplo n.º 45
0
        private static string sendMail(System.Net.Mail.MailMessage mm)
        {
            try
            {
                string smtpHost = "smtp.gmail.com";
                string userName = "******"; //write your email address
                string password = "******";       //write password
                System.Net.Mail.SmtpClient mClient = new System.Net.Mail.SmtpClient();
                mClient.Port                  = 587;
                mClient.EnableSsl             = true;
                mClient.UseDefaultCredentials = false;
                mClient.Credentials           = new NetworkCredential(userName, password);
                mClient.Host                  = smtpHost;
                mClient.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
                mClient.Send(mm);
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.Message);
            }

            return("Send Sucessfully");
        }
Exemplo n.º 46
0
        private void HyperlinkSendEmail_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_MaterialTrackingBatch.ToFacilityId == "YPBZMN")
            {
                if (this.m_MaterialTrackingBatch.MaterialTrackingLogCollection.Count > 0)
                {
                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**", System.Windows.Forms.SystemInformation.UserName, "There are slides that are being sent to you.");
                    message.To.Add("*****@*****.**");
                    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("This function currently only works for Bozeman.");
            }
        }
Exemplo n.º 47
0
        /// <summary>
        /// Realiza el envio de un email
        /// </summary>
        /// <param name="from">Remitente</param>
        /// <param name="to">A quien va dirijido</param>
        /// <param name="title">Titulo del mensaje</param>
        /// <param name="body">Cuerpo del mensaje</param>
        /// <param name="attachments">Datos adjuntos</param>
        public static void SendEmail(string from, string to,
                                     string title, string body, List <string> attachments)
        {
            System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();

            correo.From = new System.Net.Mail.MailAddress(from);
            correo.To.Add(to);
            correo.Subject    = title;
            correo.Body       = body;
            correo.IsBodyHtml = true;
            correo.Priority   = System.Net.Mail.MailPriority.Normal;

            foreach (string attach in attachments)
            {
                correo.Attachments.Add(new System.Net.Mail.Attachment(attach));
            }

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mail.casco.com.mx");
            smtp.Port        = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Tr1nyt1?");

            smtp.Send(correo);
        }
Exemplo n.º 48
0
        public string SendEmailRegisterMember(CombinedRegisterLoginModel model)
        {
            string result = "";

            try
            {
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(model.Registration.EmailAddress);
                message.Subject    = "Account Registration confirm";
                message.From       = new System.Net.Mail.MailAddress("*****@*****.**");
                message.Body       = string.Format("Hi {0}, <br/> registration confirmed. login {1} - password {2} .<br/>Thanks.", model.Registration.FirstName, model.Registration.EmailAddress, model.Registration.Password);
                message.IsBodyHtml = true;
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.Send(message);
                result = "Ok. Sent to " + model.Registration.EmailAddress;
            }
            catch (Exception ex)
            {
                result = "Error: " + ex.Message;
            }

            return(result);
        }
Exemplo n.º 49
0
        public static void SendMail(string Subject, string Body, string MailTo)
        {
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.From = new System.Net.Mail.MailAddress(FI.Common.AppConfig.SmtpSender);
            msg.To.Add(MailTo);
            msg.Subject    = Subject;
            msg.Body       = Body;
            msg.IsBodyHtml = true;

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = FI.Common.AppConfig.SmtpServer;
            if (FI.Common.AppConfig.SmtpPort != 0)
            {
                smtp.Port = FI.Common.AppConfig.SmtpPort;
            }
            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            if (FI.Common.AppConfig.SmtpUserName != null && FI.Common.AppConfig.SmtpUserName != "")
            {
                smtp.Credentials = new System.Net.NetworkCredential(FI.Common.AppConfig.SmtpUserName, FI.Common.AppConfig.SmtpPassword);
            }

            smtp.Send(msg);
        }
Exemplo n.º 50
0
        private void SendEmail(ApplicationUser user, string pass)
        {
            var m = new System.Net.Mail.MailMessage(
                new System.Net.Mail.MailAddress("{Your Email}", "Web Registration"),
                new System.Net.Mail.MailAddress(user.Email))
            {
                Subject = "Confirm E-Mail",
                Body    =
                    string.Format(
                        " Dear {0}<BR/>Thank you for Registering in our web Site please Click the link below to complete registeration: <BR/><a href=\"{1}\" title=\"User Email Confirm\">{1}</a>",
                        user.UserName,
                        Url.Action("ConfirmEmail", "Account", new { token = user.Id, email = user.Email, password = pass },
                                   Request.Url?.Scheme)),
                IsBodyHtml = true
            };

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com")
            {
                Credentials = new System.Net.NetworkCredential("[YOUR-Email]", "[YOUR PASSWORD]"),
                EnableSsl   = true
            };
            smtp.Send(m);
        }
Exemplo n.º 51
0
        public ActionResult Contato(ContatoViewModels model)
        {
            if (ModelState.IsValid)
            {
                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("*****@*****.**"));

                message.IsBodyHtml   = true;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject      = "Chamonix - contato pelo site";
                message.Body         = model.Mensagem;

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

                ViewBag.Obrigado = "Obrigado pelo contato!";
                return(View(model));
            }

            return(View(model));
        }
Exemplo n.º 52
0
        public static void SendMail(string to, string subject, string body)
        {
            try
            {
                var message = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["sender"], to)
                {
                    Subject = subject,
                    Body    = body
                };

                var smtpClient = new System.Net.Mail.SmtpClient
                {
                    EnableSsl   = true,
                    Host        = ConfigurationManager.AppSettings["smtpHost"],
                    Port        = 587,
                    Credentials = new System.Net.NetworkCredential(
                        ConfigurationManager.AppSettings["sender"],
                        ConfigurationManager.AppSettings["passwd"]),
                };
                smtpClient.Send(message);
            }
            catch { }
        }
Exemplo n.º 53
0
        public static void SendEmail(string MessageText, string Version)
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.From = new System.Net.Mail.MailAddress("*****@*****.**");
            message.To.Add("*****@*****.**");
            message.Subject = string.Format("Error message from Aerial.db - WOP");
            message.Body    = string.Format("Version: {0}\r\nMachine: {1}\r\nUser: {2}\r\nMessage: {3}",
                                            Version,
                                            System.Environment.MachineName,
                                            System.Environment.UserName,
                                            MessageText);

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com");
            client.Port = 587;
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "MjkDUBmouxNztGmm8aH-");
            client.EnableSsl             = true;

            try {
                client.SendAsync(message, null);
            }
            catch { }
        }
Exemplo n.º 54
0
        void sendEmail(string message)
        {
            //create the mail message
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            //set the addresses
            mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["errorEmailFrom"], System.Configuration.ConfigurationManager.AppSettings["ApplicationName"]);
            String[] strTo = System.Configuration.ConfigurationManager.AppSettings["errorEmailTo"].Split(",".ToCharArray());
            int      k     = 0;

            for (k = strTo.GetLowerBound(0); k <= strTo.GetUpperBound(0); k++)
            {
                mail.To.Add(strTo[k].Trim());
            }
            //set the content
            mail.Subject = System.Configuration.ConfigurationManager.AppSettings["ApplicationName"] + " Error Report";
            mail.Body    = message;

            //if we are using the IIS SMTP Service, we can write the message
            //directly to the PickupDirectory, and bypass the Network layer
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(System.Configuration.ConfigurationManager.AppSettings["errorEmailServer"]);
            //smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis
            smtp.Send(mail);
        }
        //----------Confirm Email-----------------//

        public async Task SendVerificationEmailAsync(ApplicationUser user)
        {
            var token = await userManager.GenerateEmailConfirmationTokenAsync(user);

            string body = $"<div style='border:2px solid green;border-border-radius:10px;padding:10px'>" +
                          $"HI, <b>{user.FirstName + " " + user.LastName}</b><br/>"
                          + "To confirm your account, Please use this token:" +
                          $"<h3>{token}</h3>"
                          + "<br/><b>B3hdad</b></div>";

            System.Net.Mail.MailMessage msg =
                new System.Net.Mail.MailMessage("emailaddress", user.Email);
            msg.Subject    = "Confirm Email Address";
            msg.Body       = body;
            msg.IsBodyHtml = true;
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();// "smtp.gmail.com", 465);
            client.Host        = "smtp.gmail.com";
            client.Port        = 587;
            client.EnableSsl   = true;
            client.Credentials =
                new System.Net.NetworkCredential("user", "pass");
            client.Send(msg);
        }
Exemplo n.º 56
0
        public static void SendEmail(String subject, String body, String email)
        {
            //build the email message
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["MailFrom"], email);
            mail.BodyEncoding = Encoding.Default;
            mail.Subject      = subject;
            mail.Body         = body;
            mail.IsBodyHtml   = true;

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Port                  = int.Parse(ConfigurationManager.AppSettings["MailPort"]);
            client.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = ConfigurationManager.AppSettings["UseDefaultCredentials"] == "true";
            if (client.UseDefaultCredentials)
            {
                client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["MailUserName"], ConfigurationManager.AppSettings["MailPassword"]);
                //client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["MailUserName"], ConfigurationManager.AppSettings["MailPassword"]);
                client.UseDefaultCredentials = true;
            }
            client.Host      = ConfigurationManager.AppSettings["MailServer"];
            client.EnableSsl = ConfigurationManager.AppSettings["Mail.EnableSsl"] == "true";
            client.Send(mail);
        }
Exemplo n.º 57
0
 private bool SendMail(string to, string subject, string message, string name)
 {
     try
     {
         System.Net.Mail.MailMessage  mail = new System.Net.Mail.MailMessage();
         System.Net.NetworkCredential cred = new System.Net.NetworkCredential(textBox1.Text.Trim(), textBox2.Text.Trim());
         mail.To.Add(to);
         mail.Subject    = subject;
         mail.From       = new System.Net.Mail.MailAddress(textBox3.Text, name);
         mail.IsBodyHtml = true;
         mail.Body       = message;
         System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
         smtp.UseDefaultCredentials = false;
         smtp.EnableSsl             = true;
         smtp.Credentials           = cred;
         smtp.Send(mail);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 58
0
        /// <summary>
        /// Envio de mails. Se obtiene server, remitente y destinatarios desde app_config.
        /// </summary>
        /// <param name="asunto">string que viaja en el asunto del mensaje</param>
        /// <param name="body">cuerpo del mensaje de mail</param>
        public void EnviarMail(string asunto, string body)
        {
            try
            {
                string[] _dest = System.Text.RegularExpressions.Regex.Split(System.Configuration.ConfigurationManager.AppSettings["SmtpDestinatarios"], ";");

                for (int intI = 0; intI < _dest.Length; intI++)
                {
                    System.Net.Mail.SmtpClient objMail = new System.Net.Mail.SmtpClient();
                    objMail.Host                  = System.Configuration.ConfigurationManager.AppSettings["SmtpServer"];
                    objMail.Port                  = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpPort"]);
                    objMail.EnableSsl             = (System.Configuration.ConfigurationManager.AppSettings["SmtpSSL"].ToUpper() == "S");
                    objMail.UseDefaultCredentials = true;
                    System.Net.Mail.MailMessage objMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["SmtpRemitente"], _dest[intI], asunto, body + "<p>&nbsp;</p> <p>&nbsp;</p>");
                    objMsg.IsBodyHtml = true;
                    objMail.Send(objMsg);
                }
            }
            catch (Exception ex)
            {
                AuditarExcepcion("No se pudo enviar el Mail", ex, false);
            }
        }
Exemplo n.º 59
0
 public void email()
 {
     System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
     msg.To.Add(textBox1.Text);
     msg.Subject         = "Se encontro un nuevo intruso en su red Wi-Fi";
     msg.SubjectEncoding = System.Text.Encoding.UTF8;
     msg.Body            = "Se encontro un intruso en su red Wi-Fi: ";
     msg.BodyEncoding    = System.Text.Encoding.UTF8;
     msg.From            = new System.Net.Mail.MailAddress("*****@*****.**");
     System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient();
     cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Aqui va la contraseña de tu correo");
     cliente.Port        = 587;
     cliente.EnableSsl   = true;
     cliente.Host        = "smtp.gmail.com";
     try
     {
         cliente.Send(msg);
     }
     catch (Exception)
     {
         MessageBox.Show("Error al enviar");
     }
 }
Exemplo n.º 60
-1
        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();
            }
        }