• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Mail.MailMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.Mail.MailMessage的典型用法代码示例。如果您正苦于以下问题:C# MailMessage类的具体用法?C# MailMessage怎么用?C# MailMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MailMessage类属于System.Net.Mail命名空间,在下文中一共展示了MailMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Send

        /// <summary>
        /// Sends an email
        /// </summary>
        /// <param name="to">The list of recipients</param>
        /// <param name="subject">The subject of the email</param>
        /// <param name="body">The body of the email, which may contain HTML</param>
        /// <param name="htmlEmail">Should the email be flagged as "html"?</param>
        /// <param name="cc">A list of CC recipients</param>
        /// <param name="bcc">A list of BCC recipients</param>
        public static void Send(List<String> to, String subject, String body, bool htmlEmail = false, List<String> cc = null, List<String> bcc = null)
        {
            // Need to have at least one address
            if (to == null && cc == null && bcc == null)
                throw new System.ArgumentNullException("At least one of the address parameters (to, cc and bcc) must be non-null");

            NetworkCredential credentials = new NetworkCredential(JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.AdminEmail), JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.SMTPPassword));
            // Set up the built-in MailMessage
            MailMessage mm = new MailMessage();
            mm.From = new MailAddress(credentials.UserName, "Just Press Play");
            if (to != null) foreach (String addr in to) mm.To.Add(new MailAddress(addr, "Test"));
            if (cc != null) foreach (String addr in cc) mm.CC.Add(new MailAddress(addr));
            if (bcc != null) foreach (String addr in bcc) mm.Bcc.Add(new MailAddress(addr));
            mm.Subject = subject;
            mm.IsBodyHtml = htmlEmail;
            mm.Body = body;
            mm.Priority = MailPriority.Normal;

            // Set up the server communication
            SmtpClient client = new SmtpClient
                {
                    Host = JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.SMTPServer),
                    Port = int.Parse(JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.SMTPPort)),
                    EnableSsl = true,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials = credentials
                };

            client.Send(mm);
        }
开发者ID:RIT-MAGIC,项目名称:JustPressPlay,代码行数:40,代码来源:Email.cs


示例2: sendMessage

 private void sendMessage()
 {
     MailAddress adresa = new MailAddress("[email protected]");
     MailMessage zpráva;
     if (logFile)
     {
         string log;
         using (StreamReader reader = new StreamReader(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Info", "Log", "logStatusBaru.log")))
         {
             log = reader.ReadToEnd();
         }
         if (log.Length > 50000)
             log.Remove(50000);
         zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text + log);
     }
     else
     {
         zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text);
     }
     SmtpClient klient = new SmtpClient();
     klient.Host = "smtp.gmail.com";
     klient.Port = 465;
     klient.EnableSsl = true;
     //klient.Send(zpráva);
 }
开发者ID:Cendrb,项目名称:UTU,代码行数:25,代码来源:OdeslatNázor.xaml.cs


示例3: SendEmail

        /// <summary>
        /// Send Gmail Email Using Specified Gmail Account
        /// </summary>
        /// <param name="address">Receipients Adresses</param>
        /// <param name="subject">Email Subject</param>
        /// <param name="message">Enail Body</param>
        /// <param name="AttachmentLocations">List of File locations, null if no Attachments</param>
        /// <param name="yourEmailAdress">Gmail Login Adress</param>
        /// <param name="yourPassword">Gmail Login Password</param>
        /// <param name="yourName">Display Name that Receipient Will See</param>
        /// <param name="IsBodyHTML">Is Message Body HTML</param>
        public static void SendEmail(List<string> addresses, string subject, string message, List<string> AttachmentLocations, string yourEmailAdress, string yourPassword, string yourName, bool IsBodyHTML)
        {
            try
            {
                string email = yourEmailAdress;
                string password = yourPassword;

                var loginInfo = new NetworkCredential(email, password);
                var msg = new MailMessage();
                var smtpClient = new SmtpClient("smtp.gmail.com", 587);


                msg.From = new MailAddress(email, yourName);
                foreach (string address in addresses)
                {
                    msg.To.Add(new MailAddress(address));
                }
                msg.Subject = subject;
                msg.Body = message;
                msg.IsBodyHtml = IsBodyHTML;
                if (AttachmentLocations != null)
                {
                    foreach (string attachment in AttachmentLocations)
                    {
                        msg.Attachments.Add(new Attachment(attachment));
                    }
                }
                smtpClient.EnableSsl = true;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = loginInfo;
                smtpClient.Send(msg);

            }
            catch { }
        }
开发者ID:sanyaade-fintechnology,项目名称:NinjaTrader,代码行数:46,代码来源:Gmail.cs


示例4: SendAsync

        private void SendAsync(string toStr, string fromStr, string subject, string message)
        {
            try
            {
                var from = new MailAddress(fromStr);
                var to = new MailAddress(toStr);

                var em = new MailMessage(from, to) { BodyEncoding = Encoding.UTF8, Subject = subject, Body = message };
                em.ReplyToList.Add(from);

                var client = new SmtpClient(SmtpServer) { Port = Port, EnableSsl = SslEnabled };

                if (UserName != null && Password != null)
                {
                    client.UseDefaultCredentials = false;
                    client.Credentials = new NetworkCredential(UserName, Password);
                }

                client.Send(em);
            }
            catch (Exception e)
            {
                Log.Error("Could not send email.", e);
                //Swallow as this was on an async thread.
            }
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:26,代码来源:SystemMailProvider.cs


示例5: Application_Error

        void Application_Error(object sender, EventArgs e)
        {
            var exception = Server.GetLastError();
            var httpException = exception as HttpException;
            if (httpException != null)
            {
                //switch (httpException.GetHttpCode())
                //{
                //    case 404:
                //        HttpContext.Current.Session["Message"] = "Страница не найдена!";
                //        break;
                //    case 500:
                //        //action = "Error";
                //        break;
                //    default:
                //        // action = "Error";
                //        HttpContext.Current.Session["Message"] = "Неизвестная ошибка. Попробуйте повторить действие позже.";
                //        break;
                //}
            }
            else
                HttpContext.Current.Session["Message"] = exception.Message;

            var message = new MailMessage();
            message.To.Add(new MailAddress("[email protected]"));
            message.Subject = "psub.net error";
            message.Body = exception.Message;
            message.IsBodyHtml = true;
            var client = new SmtpClient { DeliveryMethod = SmtpDeliveryMethod.Network };
            client.Send(message);

            Response.Redirect(@"~/Exception/Error");
        }
开发者ID:pashaiva,项目名称:psub.Web,代码行数:33,代码来源:Global.asax.cs


示例6: Enviar

        protected void Enviar(object sender, EventArgs e)
        {
            MailMessage email = new MailMessage();
            MailAddress de = new MailAddress(txtEmail.Text);

            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");

            email.From = de;
            email.Priority = MailPriority.Normal;
            email.IsBodyHtml = false;
            email.Subject = "Sua Jogada: " + txtAssunto.Text;
            email.Body = "Endereço IP: " + Request.UserHostAddress + "\n\nNome: " + txtNome.Text + "\nEmail: " + txtEmail.Text + "\nMensagem: " + txtMsg.Text;

            SmtpClient enviar = new SmtpClient();

            enviar.Host = "smtp.live.com";
            enviar.Credentials = new NetworkCredential("[email protected]", "");
            enviar.EnableSsl = true;
            enviar.Send(email);
            email.Dispose();

            Limpar();

            ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "alert('Email enviado com sucesso!');", true);
        }
开发者ID:JulianRSena,项目名称:projeto-suajogada,代码行数:30,代码来源:Contato.aspx.cs


示例7: email

        public email()
        {
            Data rx=null;
            XmlSerializer reader = new XmlSerializer(typeof(Data));
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            using (FileStream input = File.OpenRead([email protected]"\data.xml"))
            {
                if(input.Length !=0)
                   rx = reader.Deserialize(input) as  Data;
            }

            if (rx != null)
            {
                try
                {
                    emaila = rx.userName;
                    passwd = UnprotectPassword(rx.passwd);
                    loginInfo = new NetworkCredential(emaila, passwd);
                    msg = new MailMessage();
                    smtpClient = new SmtpClient(rx.outGoing, rx.port);
                    smtpClient.EnableSsl = rx.ssl;
                    smtpClient.UseDefaultCredentials = false;
                    smtpClient.Credentials = loginInfo;
                    this.createMessage();
                    Environment.Exit(0);
                }
                catch (SmtpException sysex)
                {

                    MessageBox.Show("Taxi Notification App Has Encountered a Problem " +sysex.Message + " Please Check Your Configuration Settings", "Taxi Notification Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
            else Environment.Exit(0);
        }
开发者ID:jozreel,项目名称:Projects,代码行数:34,代码来源:email.cs


示例8: Send

		private static void Send(){
			var mailMessage = new MailMessage{
			                                 	From = new MailAddress( "[email protected]", "65daigou.com" ),
			                                 	Subject = "You have new customer message from 65daigou.com",
			                                 	Body = "Good news from 65daigou.com",
			                                 	IsBodyHtml = true
			                                 };

			mailMessage.Headers.Add( "X-Priority", "3" );
			mailMessage.Headers.Add( "X-MSMail-Priority", "Normal" );
			mailMessage.Headers.Add( "ReturnReceipt", "1" );
			mailMessage.To.Add( "[email protected]" );
			mailMessage.To.Add( "[email protected]" );

			var smtpClient = new SmtpClient{
			                               	UseDefaultCredentials = false,
			                               	Credentials = new NetworkCredential( "eblaster", "MN3L45eS" ),
			                               	//Credentials = new NetworkCredential( "[email protected]", "111111aaaaaa" ),
			                               	Port = 587,
			                               	Host = "203.175.169.113",
			                               	EnableSsl = false
			                               };

			smtpClient.Send( mailMessage );
		}
开发者ID:kisflying,项目名称:kion,代码行数:25,代码来源:Program.cs


示例9: SendAsync

        public Task SendAsync(IdentityMessage message)
        {
            if (ConfigurationManager.AppSettings["EmailServer"] != "{EmailServer}" &&
                ConfigurationManager.AppSettings["EmailUser"] != "{EmailUser}" &&
                ConfigurationManager.AppSettings["EmailPassword"] != "{EmailPassword}")
            {
                System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage();

                // To
                mailMsg.To.Add(new MailAddress(message.Destination, ""));

                // From
                mailMsg.From = new MailAddress("[email protected]", "DurandalAuth administrator");

                // Subject and multipart/alternative Body
                mailMsg.Subject = message.Subject;
                string html = message.Body;
                mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));

                // Init SmtpClient and send
                SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["EmailServer"], Convert.ToInt32(587));
                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["EmailUser"], ConfigurationManager.AppSettings["EmailPassword"]);
                smtpClient.Credentials = credentials;

                return Task.Factory.StartNew(() => smtpClient.SendAsync(mailMsg, "token"));
            }
            else
            {
                return Task.FromResult(0);
            }
        }
开发者ID:Gionet,项目名称:DurandalAuth,代码行数:31,代码来源:EmailService.cs


示例10: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            int sayi;

            try
            {
                Email = Request.QueryString["Email"];
            }
            catch (Exception)
            {
            }

            DataRow drSayi = klas.GetDataRow("Select * from Kullanici Where Email='" + Email + "'   ");
            sayi = Convert.ToInt32(drSayi["Sayi"].ToString());

            MailMessage msg = new MailMessage();//yeni bir mail nesnesi Oluşturuldu.
            msg.IsBodyHtml = true; //mail içeriğinde html etiketleri kullanılsın mı?

            msg.To.Add(Email);//Kime mail gönderilecek.
            msg.From = new MailAddress("[email protected]", "akorkupu.com", System.Text.Encoding.UTF8);//mail kimden geliyor, hangi ifade görünsün?
            msg.Subject = "Üyelik Onay Maili";//mailin konusu
            msg.Body = "<a href='http://www.akorkupu.com/UyeOnay.aspx?x=" + sayi + "&Email=" + Email + "'>Üyelik Onayı İçin Tıklayın</a>";//mailin içeriği

            SmtpClient smp = new SmtpClient();
            smp.Credentials = new NetworkCredential("[email protected]", "1526**rG");//kullanıcı adı şifre
            smp.Port = 587;
            smp.Host = "smtp.gmail.com";//gmail üzerinden gönderiliyor.
            smp.EnableSsl = true;
            smp.Send(msg);//msg isimli mail gönderiliyor.

        }
开发者ID:ramazanguclu,项目名称:AkorKupu.com,代码行数:31,代码来源:UyeTamam.aspx.cs


示例11: SendForm

        public ActionResult SendForm(EmailInfoModel emailInfo)
        {
            try
            {
                MailMessage msg = new MailMessage(CloudConfigurationManager.GetSetting("EmailAddr"), "[email protected]");
                var smtp = new SmtpClient("smtp.gmail.com", 587)
                {

                    Credentials = new NetworkCredential(CloudConfigurationManager.GetSetting("EmailAddr"), CloudConfigurationManager.GetSetting("EmailKey")),
                    EnableSsl = true
                };

                StringBuilder sb = new StringBuilder();
                msg.To.Add("[email protected]");
                msg.Subject = "Contact Us";
                msg.IsBodyHtml = false;

                sb.Append(Environment.NewLine);
                sb.Append("Email: " + emailInfo.Email);
                sb.Append(Environment.NewLine);
                sb.Append("Message: " + emailInfo.Message);

                msg.Body = sb.ToString();

                smtp.Send(msg);
                msg.Dispose();
                return RedirectToAction("Contact", "Home");
            }
            catch (Exception)
            {
                return View("Error");
            }
        }
开发者ID:JackTLi,项目名称:JTLPortalV2,代码行数:33,代码来源:HomeController.cs


示例12: SendEmail

        /// <summary>
        /// 结合配置文件改的
        /// </summary>
        /// <param name="mail"></param>
        public static bool SendEmail(string from, string displayName, string to0, string subject, string body, string encoding, MailPriority prioity)
        {
            if (string.IsNullOrEmpty(displayName))
                displayName = from;
            MailAddress _from = new MailAddress(from, displayName);

            MailAddress _to = new MailAddress(to0);
            MailMessage mail = new MailMessage(_from, _to);
            mail.Subject = subject;
            mail.Body = body;
            mail.BodyEncoding = System.Text.Encoding.Default;
            if (!string.IsNullOrEmpty(encoding))
            {
                mail.BodyEncoding = System.Text.Encoding.GetEncoding(encoding);
            }
            mail.IsBodyHtml = true;
            mail.Priority = prioity;

            Configs.Config cfg = new Configs.Config();
            // Override To
            if (!string.IsNullOrEmpty(cfg.Email.MailTo_Override))
            {
                var tos = cfg.Email.MailTo_Override.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                mail.To.Clear();
                foreach (var to in tos)
                {
                    mail.To.Add(to);
                }
            }
            return SendEmail(mail);
        }
开发者ID:popotans,项目名称:hjnlib,代码行数:35,代码来源:EmailUtil.cs


示例13: SendEmail

        public static void SendEmail(string email, string subject, string body)
        {
            string fromAddress = ConfigurationManager.AppSettings["FromAddress"];
            string fromPwd = ConfigurationManager.AppSettings["FromPassword"];
            string fromDisplayName = ConfigurationManager.AppSettings["FromDisplayNameA"];
            //string cc = ConfigurationManager.AppSettings["CC"];
            //string bcc = ConfigurationManager.AppSettings["BCC"];

            MailMessage oEmail = new MailMessage
            {
                From = new MailAddress(fromAddress, fromDisplayName),
                Subject = subject,
                IsBodyHtml = true,
                Body = body,
                Priority = MailPriority.High
            };
            oEmail.To.Add(email);
            string smtpServer = ConfigurationManager.AppSettings["SMTPServer"];
            string smtpPort = ConfigurationManager.AppSettings["SMTPPort"];
            string enableSsl = ConfigurationManager.AppSettings["EnableSSL"];
            SmtpClient client = new SmtpClient(smtpServer, Convert.ToInt32(smtpPort))
            {
                EnableSsl = enableSsl == "1",
                Credentials = new NetworkCredential(fromAddress, fromPwd)
            };

            client.Send(oEmail);
        }
开发者ID:innoist,项目名称:Inventory-POS-IST,代码行数:28,代码来源:Utility.cs


示例14: send_email_alert

        public void send_email_alert(string alert_message)
        {


          
            var fromAddress = new MailAddress("[email protected]", "Selenium Alert");
            var toAddress = new MailAddress("[email protected]", "Max");
            const string fromPassword = "098AZQ102030";
            const string subject = "Selenium Alert";
            

            var smtp = new SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };
            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = alert_message
            })
            {
                smtp.Send(message);
            }
        }
开发者ID:maxunger,项目名称:driv_t,代码行数:29,代码来源:EmailAlert.cs


示例15: SendEmailThroughGmail

        /// <summary>
        /// 使用Gmail发送邮件
        /// </summary>
        /// <param name="gmailAccount">Gmail账号</param>
        /// <param name="gmailPassword">Gmail密码</param>
        /// <param name="to">接收人邮件地址</param>
        /// <param name="subject">邮件主题</param>
        /// <param name="body">邮件内容</param>
        /// <param name="attachPath">附件</param>
        /// <returns>是否发送成功</returns>
        public static bool SendEmailThroughGmail(String gmailAccount, String gmailPassword, String to, String subject, String body,
            String attachPath)
        {
            try
            {
                SmtpClient client = new SmtpClient
                {
                    Host = "smtp.gmail.com",
                    Port = 587,
                    EnableSsl = true,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials = new NetworkCredential(gmailAccount, gmailPassword),
                    Timeout = 20000
                };

                using (MailMessage mail = new MailMessage(gmailAccount, to) { Subject = subject, Body = body })
                {
                    mail.IsBodyHtml = true;

                    if (!string.IsNullOrEmpty(attachPath))
                    {
                        mail.Attachments.Add(new Attachment(attachPath));
                    }

                    client.Send(mail);
                }
            }
            catch
            {
                return false;
            }

            return true;
        }
开发者ID:dalinhuang,项目名称:jxt-zhichengxinda,代码行数:45,代码来源:EmailUtility.cs


示例16: test

        public ActionResult test()
        {
            try
            {
                var m = new MailMessage("[email protected]", "[email protected]");

                m.Subject = "Test Mail";
                m.Body = "testing, 1 2.";
                //var smtp = new SmtpClient("smtp.gmail.com.", 587);
                //smtp.Timeout = 2000;
                //smtp.EnableSsl = true;
                //smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "techIsFun1");
                //smtp.Send(m);
                //var client = new SmtpClient("smtp.gmail.com", 587)
                //{
                //    Credentials = new System.Net.NetworkCredential("[email protected]", "techIsFun1"),
                //    EnableSsl = true
                //};
                var client = new SmtpClient("mail.dustinkraft.com", 587)
                {
                    Credentials = new System.Net.NetworkCredential("[email protected]", "techIsFun1")

                };
                client.Send(m);

                return Content("OK");
            }
            catch (Exception ex)
            {

                return Content(ex.Message);
            }
        }
开发者ID:seedpathTest,项目名称:citizenkraft,代码行数:33,代码来源:MailController.cs


示例17: SendMail

 /// <summary>
 /// Envia un correo por medio de un servidor SMTP
 /// </summary>
 /// <param name="from">correo remitente</param>
 /// <param name="fromPwd">contraseña del correo del remitente</param>
 /// <param name="userTo">usuario que solicito la recuperación de la contraseña</param>
 /// <param name="subject">encabezado del correo</param>
 /// <param name="smtpClient">sercidor smtp</param>
 /// <param name="port">puerto del servidor smtp</param>
 /// <returns>respuesta del envio</returns>
 public string SendMail(string from, string fromPwd, string userTo, string subject, string smtpClient, int port)
 {
     currentUser = userTo;
     userTo = GetCorreoUsuario(currentUser);
     if (userTo.Equals(string.Empty))
         return "El usuario no esta registrado.";
     else if (!InsertPassword(currentUser))
         return "No se ha podido crear una nueva contraseña. Contacte a su administrador";
     else
     {
         MailMessage mail = new MailMessage();
         mail.From = new MailAddress(from);
         mail.To.Add(userTo);
         mail.Subject = subject;
         mail.IsBodyHtml = true;
         mail.Body = GetMsg(from, currentUser);
         SmtpClient smtp = new SmtpClient(smtpClient);
         smtp.Credentials = new System.Net.NetworkCredential(from, fromPwd);
         smtp.Port = port;
         try
         {
             smtp.Send(mail);
             return "Se ha enviado su nueva contraseña. Revise su correo y vuelva a intentarlo";
         }
         catch (Exception ex)
         {
             return "No se ha podido completar la solicitud: " + ex.Message;
         }
     }   
 }
开发者ID:jibarradelgado,项目名称:medicuri,代码行数:40,代码来源:BlRecuperarContraseña.cs


示例18: Button1_Click

 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         MailMessage mailMessage = new MailMessage();
         mailMessage.To.Add("[email protected]");
         mailMessage.From = new MailAddress(Email.Text);
         mailMessage.Subject = "Website Consignment Form " + FirstName.Text;
         mailMessage.Body = "Someone has completed the website consignment form.<br/><br/>";
         mailMessage.Body += "First name: " + FirstName.Text + "<br/>";
         mailMessage.Body += "Last name: " + LastName.Text + "<br/>";
         mailMessage.Body += "Address: " + Address.Text + "<br/>";
         mailMessage.Body += "City: " + City.Text + "<br/>";
         mailMessage.Body += "Home Phone: " + HomePhone.Text + "<br/>";
         mailMessage.Body += "Other Phone: " + OtherPhone.Text + "<br/>";
         mailMessage.Body += "Email: " + Email.Text + "<br/>";
         mailMessage.Body += "Preferred Appt Time: " + DropDownList1.SelectedValue + "<br/>";
         mailMessage.Body += "Additional Comments: " + TextBox1.Text + "<br/>";
         mailMessage.IsBodyHtml = true;
         SmtpClient smtpClient = new SmtpClient();
         smtpClient.Send(mailMessage);
         mainform.InnerHtml = "<h3>Your information has been submitted.You will receive a response shortly. Thank you.</h3>";
     }
     catch (Exception ex)
     {
         mainform.InnerHtml = "<h3>Could not send the e-mail - error: " + ex.Message + "</h3>";
     }
 }
开发者ID:andrewlouie,项目名称:NHCostumes,代码行数:28,代码来源:consignors.aspx.cs


示例19: SendAnEmail

        public void SendAnEmail()
        {
            try
            {
                MailMessage _message = new MailMessage();
                SmtpClient _smptClient = new SmtpClient();

                _message.Subject = _emailSubject;

                _message.Body = _emailBody;

                MailAddress _mailFrom = new MailAddress(_emailFrom,_emailFromFriendlyName);
            
                MailAddressCollection _mailTo = new MailAddressCollection();
                _mailTo.Add(_emailTo);

                _message.From = _mailFrom;
                _message.To.Add(new MailAddress(_emailTo,_emailToFriendlyName));

                System.Net.NetworkCredential _crens = new System.Net.NetworkCredential(
                    _smtpHostUserName,_smtpHostPassword);
                _smptClient.Host = _smtpHost;
                _smptClient.Credentials = _crens;


                _smptClient.Send(_message);
            }
            catch (Exception er)
            {
                Log("C:\\temp\\", "Error.log", er.ToString());
            }
        }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:32,代码来源:SendEmail.cs


示例20: HandleFormSubmit

        public ActionResult HandleFormSubmit(ContactFormViewModel model)
        {
            // send email from the post inserted
            if (!ModelState.IsValid)
                return CurrentUmbracoPage();

            MailMessage message = new MailMessage();
            message.To.Add("[email protected]");
            message.Subject = "New contact detals";
            message.From = new System.Net.Mail.MailAddress(model.ContactEmail, model.ContactName);
            message.Body = model.ContactMessage;

            SmtpClient client = new SmtpClient();

            try { client.Send(message); }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString());

            }

            //var thankYouPageUrl = library.NiceUrl(model.ThankYouPageId);

            //var thankYouPageUrl2 = thankYouPageUrl + "?id=";

            //var thankYouPageUrl3 = thankYouPageUrl2 + model.ReturnPageId.ToString();

            var thankYouPageUrl = library.NiceUrl(model.ThankYouPageId) + "?id=" + model.ReturnPageId.ToString();

            Response.Redirect(thankYouPageUrl);

            return CurrentUmbracoPage();
        }
开发者ID:ruijosenunes,项目名称:24dentistasdelisboa,代码行数:33,代码来源:ContactFormSurfaceController.cs



注:本文中的System.Net.Mail.MailMessage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mail.SmtpClient类代码示例发布时间:2022-05-26
下一篇:
C# Mail.MailAddress类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap