public ActionResult HandleFormSubmit(ContactFormViewModel model) { // send email from the post inserted if (!ModelState.IsValid) return CurrentUmbracoPage(); MailMessage message = new MailMessage(); message.To.Add("*****@*****.**"); 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(); }
/// <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 { } }
/// <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); }
private void sendMessage() { MailAddress adresa = new MailAddress("*****@*****.**"); 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("*****@*****.**", "*****@*****.**", předmětTextBox.Text, textZprávyTextBox.Text + log); } else { zpráva = new MailMessage("*****@*****.**", "*****@*****.**", 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); }
public static void SendMessage(SmtpServer server, string from, string to, string subject, string content) { // compress Foe message and convert the compressed data to Base64 string byte[] compressedData = Foe.Common.CompressionManager.Compress(Encoding.UTF8.GetBytes(content)); string based64 = Convert.ToBase64String(compressedData); // send email try { // create mail MailMessage mail = new MailMessage(from, to, subject, based64); // connect and send SmtpClient smtp = new SmtpClient(server.ServerName, server.Port); if (server.AuthRequired) { smtp.EnableSsl = server.SslEnabled; smtp.UseDefaultCredentials = false; NetworkCredential cred = new NetworkCredential(server.UserName, server.Password); smtp.Credentials = cred; } smtp.Send(mail); } catch (Exception except) { throw except; } }
public static void Send(Mail mail) { MailMessage msg = new MailMessage(); msg.From = new MailAddress(mail.From, "Money Pacific Service"); msg.To.Add(new MailAddress(mail.To)); msg.Subject = mail.Subject; msg.Body = mail.Body; msg.IsBodyHtml = true; msg.BodyEncoding = new System.Text.UTF8Encoding(); msg.Priority = MailPriority.High; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; System.Net.NetworkCredential user = new System.Net.NetworkCredential( ConfigurationManager.AppSettings["sender"], ConfigurationManager.AppSettings["senderPass"] ); smtp.EnableSsl = true; smtp.Credentials = user; smtp.Port = 587; //or use 465 object userState = msg; try { //you can also call client.Send(msg) smtp.SendAsync(msg, userState); } catch (SmtpException) { //Catch errors... } }
public void send_email_alert(string alert_message) { var fromAddress = new MailAddress("*****@*****.**", "Selenium Alert"); var toAddress = new MailAddress("*****@*****.**", "Max"); const string fromPassword = "******"; 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); } }
public email() { Data rx=null; XmlSerializer reader = new XmlSerializer(typeof(Data)); string appPath = Path.GetDirectoryName(Application.ExecutablePath); using (FileStream input = File.OpenRead(appPath+@"\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); }
protected void Enviar(object sender, EventArgs e) { MailMessage email = new MailMessage(); MailAddress de = new MailAddress(txtEmail.Text); email.To.Add("*****@*****.**"); email.To.Add("*****@*****.**"); email.To.Add("*****@*****.**"); email.To.Add("*****@*****.**"); email.To.Add("*****@*****.**"); email.To.Add("*****@*****.**"); 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("*****@*****.**", ""); enviar.EnableSsl = true; enviar.Send(email); email.Dispose(); Limpar(); ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "alert('Email enviado com sucesso!');", true); }
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. } }
// email from contact form public void SendContactEmail(Registrant registrant) { emailBody += "NAME: " + registrant.FirstName + " " + registrant.LastName; emailBody += "<br><br>"; emailBody += "EMAIL: " + registrant.Email; emailBody += "<br><br>"; emailBody += "ZIP: " + registrant.ZipCode; emailBody += "<br><br>"; emailBody += "COMMENTS:"; emailBody += "<br><br>"; emailBody += registrant.Comments; var message = new MailMessage(SMTPAddress, contactAddress) { Subject = "Contact Inquiry from Website", IsBodyHtml = true, Body = emailBody }; var mailer = new SmtpClient(); mailer.Host = SMTPHost; mailer.Credentials = new System.Net.NetworkCredential(SMTPAddress, SMTPPassword); mailer.Send(message); return; }
public void Send_with_Auth_Success_Test() { using (var server = new SmtpServerForUnitTest( address: IPAddress.Loopback, port: 2525, credentials: new[] { new NetworkCredential("*****@*****.**", "p@$$w0rd") })) { server.Start(); var client = new SmtpClient("localhost", 2525); client.Credentials = new NetworkCredential("*****@*****.**", "p@$$w0rd"); client.Send( "*****@*****.**", "[email protected],[email protected]", "[HELLO WORLD]", "Hello, World."); server.ReceivedMessages.Count().Is(1); var msg = server.ReceivedMessages.Single(); msg.MailFrom.Is("<*****@*****.**>"); msg.RcptTo.OrderBy(_ => _).Is("<*****@*****.**>", "<*****@*****.**>"); msg.From.Address.Is("*****@*****.**"); msg.To.Select(_ => _.Address).OrderBy(_ => _).Is("*****@*****.**", "*****@*****.**"); msg.CC.Count().Is(0); msg.Subject.Is("[HELLO WORLD]"); msg.Body.Is("Hello, World."); } }
public void Send(SPWeb web, IEnumerable<string> emailTo, string senderDisplayName, string subject, string body) { if (web == null) throw new ArgumentNullException("web"); if (emailTo == null || !emailTo.Any()) throw new ArgumentNullException("emailTo"); var webApplication = web.Site.WebApplication; var from = new MailAddress(webApplication.OutboundMailSenderAddress, senderDisplayName); var message = new MailMessage { IsBodyHtml = true, Body = body, From = from }; var smtpServer = webApplication.OutboundMailServiceInstance; var smtp = new SmtpClient(smtpServer.Server.Address); foreach (var email in emailTo) { message.To.Add(email); } message.Subject = subject; smtp.Send(message); }
/// <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; }
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("*****@*****.**")); 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"); }
public Boolean Send(String toEmail, String toFriendlyName, String subject, String HTML) { try { SmtpClient smtpclient = new SmtpClient(); smtpclient.Host = this.smtpserver; smtpclient.Credentials = new System.Net.NetworkCredential(this.smtpusername, this.smtppassword); smtpclient.Port = this.smtpport; smtpclient.EnableSsl = this.smtpssl; MailMessage message = new MailMessage(); message.To.Add(new MailAddress(toEmail, toFriendlyName)); message.From = new MailAddress(this.emailfromaddress, this.emailfromfriendly); message.ReplyToList.Add(new MailAddress(this.emailreplyaddress, this.emailfromfriendly)); message.Subject = subject; message.SubjectEncoding = Encoding.UTF8; message.IsBodyHtml = true; message.Body = HTML; message.BodyEncoding = Encoding.UTF8; smtpclient.Send(message); return true; } catch (Exception ex) { this.errormessage = ex.Message; return false; } }
protected void Button1_Click(object sender, EventArgs e) { DataView DV1 = (DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty); foreach (DataRowView DRV1 in DV1) { string ToAddress = DRV1["Email_Address"].ToString(); MailMessage message = new MailMessage("*****@*****.**", ToAddress); message.Body = TextBox2.Text; message.Subject = TextBox1.Text; message.BodyEncoding = System.Text.Encoding.UTF8; string Path = HttpContext.Current.Server.MapPath("~/images/EnewsLetters/Temp/"); FileUpload1.SaveAs(Path + FileUpload1.FileName); Attachment attach1 = new Attachment(Path + FileUpload1.FileName); message.Attachments.Add(attach1); SmtpClient mailserver = new SmtpClient("amcsmail02.amcs.com", 25); try { mailserver.Send(message); } catch { } attach1.Dispose(); } System.IO.File.Delete(HttpContext.Current.Server.MapPath("~/images/EnewsLetters/Temp/") + FileUpload1.FileName); TextBox1.Text = ""; TextBox2.Text = ""; }
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()); } }
/// <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; } } }
/// <summary> /// Sends an E-mail with the EMailClass Object Information /// </summary> /// <param name="oEMailClass">Mail's Propierties Class</param> public void EnviarEMailClass(EMailClass oEMailClass) { try { MailMessage oMailMessage = new MailMessage(); oMailMessage.To.Add(oEMailClass.To); if (!string.IsNullOrEmpty(oEMailClass.CC)) oMailMessage.CC.Add(oEMailClass.CC); oMailMessage.Subject = oEMailClass.Subject; oMailMessage.From = new MailAddress(ConfigurationManager.AppSettings["MailUser"].ToString()); oMailMessage.IsBodyHtml = true; if (!string.IsNullOrEmpty(oEMailClass.Attachment)) oMailMessage.Attachments.Add(new Attachment(oEMailClass.Attachment)); oMailMessage.Body = oEMailClass.Message; oMailMessage.Priority = MailPriority.Normal; SmtpClient oSmtpClient = new SmtpClient(ConfigurationManager.AppSettings["MailSmtp"].ToString()); oSmtpClient.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["MailUser"].ToString(), ConfigurationManager.AppSettings["MailPass"].ToString()); oSmtpClient.Send(oMailMessage); oMailMessage.Dispose(); } catch (SmtpException ex) { throw new SmtpException("Houve um problema no envio de e-mail \n" + ex.ToString()); } }
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("*****@*****.**", "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("*****@*****.**", "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. }
public static void sendEmail(string emailFrom, string password, string emailTo, string subject, string body) { string smtpAddress = "smtp.gmail.com"; int portNumber = 587; bool enableSSL = true; using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress(emailFrom); //email của mình mail.To.Add(emailTo); //gửi tới ai mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; // Can set to false, if you are sending pure text. //mail.Attachments.Add(new Attachment("H:\\cpaior2012_path.pdf")); using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber)) { smtp.Credentials = new NetworkCredential(emailFrom, password); smtp.EnableSsl = enableSSL; smtp.Send(mail); } } }
private static void Send(){ var mailMessage = new MailMessage{ From = new MailAddress( "*****@*****.**", "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( "*****@*****.**" ); mailMessage.To.Add( "*****@*****.**" ); var smtpClient = new SmtpClient{ UseDefaultCredentials = false, Credentials = new NetworkCredential( "eblaster", "MN3L45eS" ), //Credentials = new NetworkCredential( "*****@*****.**", "111111aaaaaa" ), Port = 587, Host = "203.175.169.113", EnableSsl = false }; smtpClient.Send( mailMessage ); }
/// <summary> /// Sends an email /// </summary> /// <param name="Message">The body of the message</param> public void SendMail(string Message) { try { System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); char[] Splitter = { ',' }; string[] AddressCollection = to.Split(Splitter); for (int x = 0; x < AddressCollection.Length; ++x) { message.To.Add(AddressCollection[x]); } message.Subject = subject; message.From = new System.Net.Mail.MailAddress((from)); message.Body = Message; message.Priority = Priority_; message.SubjectEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); message.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); message.IsBodyHtml = true; if (Attachment_ != null) { message.Attachments.Add(Attachment_); } System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(Server,Port); if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password)) { smtp.Credentials = new System.Net.NetworkCredential(UserName,Password); } smtp.Send(message); message.Dispose(); } catch (Exception e) { throw new Exception(e.ToString()); } }
static void SendMail( string _receivers, string subject, string content, string attachments) { string[] receivers = _receivers.Split(';'); string sender = "*****@*****.**"; MailMessage msg = new MailMessage(sender, receivers[0]) { Body = content, BodyEncoding = Encoding.UTF8, IsBodyHtml = false, Priority = MailPriority.Normal, ReplyTo = new MailAddress(sender), Sender = new MailAddress(sender), Subject = subject, SubjectEncoding = Encoding.UTF8, }; for (int i = 1; i < receivers.Length; ++i) msg.CC.Add(receivers[i]); if (!string.IsNullOrEmpty(attachments)) { foreach (var fileName in attachments.Split(';')) { msg.Attachments.Add(new Attachment(fileName)); } } SmtpClient client = new SmtpClient("smtp.126.com", 25) { Credentials = new System.Net.NetworkCredential("testuser", "123456"), EnableSsl = true, }; client.Send(msg); }
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); }
public ActionResult SendForm(EmailInfoModel emailInfo) { try { MailMessage msg = new MailMessage(CloudConfigurationManager.GetSetting("EmailAddr"), "*****@*****.**"); 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("*****@*****.**"); 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"); } }
public string SendMail(string from, string passsword, string to, string bcc, string cc, string subject, string body, string UserName = "", string Password = "") { string response = ""; try { using (SmtpClient smtp = new SmtpClient()) { MailMessage mail = new MailMessage(); mail.To.Add(to); mail.From = new MailAddress(UserName); mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Host = "smtp.zoho.com"; smtp.Port = 587; smtp.Credentials = new NetworkCredential(UserName, Password); smtp.Send(mail); response = "Success"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.Message); } return response; }
public bool SendMail() { MailMessage message = new MailMessage(FromAddress, ToAddress, Subject, MessageText); SetServer(); SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = EnableSSL; client.Port = Port; if (Encrypted) { } message.CC.Add(CC); message.Bcc.Add(BCC); client.Host = _SMTPServer; client.UseDefaultCredentials = false; NetworkCredential credential = new NetworkCredential(_SMTPUsername, _SMTPPassword); credential.GetCredential(client.Host, Port, AuthenticationType); client.Credentials = credential; message.ReplyTo = message.From; try { client.Send(message); } catch(Exception err) { MMDBExceptionHandler.HandleException(err); throw(err); } return true; }
protected void Button1_Click(object sender, EventArgs e) { try { MailMessage mailMessage = new MailMessage(); mailMessage.To.Add("*****@*****.**"); 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>"; } }
private void SendMail(string emailId, string password) { try { string url = ConfigurationManager.AppSettings["mailPath"].ToString();//"https://www.ziddu.com/"; string body = string.Format("Dear User!<br><br>You have requested for your password.<br><br>Your password is: {0}<br>If you need any further help,<a href=\"{1}contact.aspx\" target=\"_blank\">click here</a><br><br>Thank you,<br><br>Ziddu Team", password, url); System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["emailAddress"].ToString(), emailId, "Password for Ziddu.com", body); //msg.Bcc.Add("*****@*****.**"); System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("31.3.223.108"); smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["emailAddress"].ToString(), ConfigurationManager.AppSettings["emailPwd"].ToString()); msg.IsBodyHtml = true; smtp.Send(msg); } catch (Exception ex) { } }
protected void SendMail() { System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.To.Add("*****@*****.**"); //message.Bcc.Add("*****@*****.**"); message.Subject = "Quote Request from " + this.txtName.Text; message.From = new System.Net.Mail.MailAddress("*****@*****.**"); message.Body = "Message from:\t" + this.txtName.Text + "\n" + "Email Address:\t" + this.txtEmail.Text + "\n" + "Services Requested: \n" + (this.DDL1.SelectedItem.Text) + '\n' + "Project Details: \n" + "\t" + this.txtDetails.Text; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mail.gemini-tech.net"); smtp.Port = 8889; System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential("*****@*****.**", "T@hd2d62"); smtp.Credentials = Credentials; smtp.Send(message); }
private void SendMail(string emailId, string password, string gid) { try { //string url = string.Format("https://www.ziddu.com/verify.aspx?email={0}&vlink={1}", emailId, gid); string url = string.Format(ConfigurationManager.AppSettings["mailPath"].ToString() + "verify.aspx?email={0}&vlink={1}", emailId, gid); string body = string.Format("Dear User!<br><br>Welcome to Ziddu.com!!<br><br>Congratulations to be part of Ziddu.com and now you can avail Global Wallet.<br><br>Your Ziddu ID : {0}<br>Password : {1}<br><br><a href=\"{2}\" target=\"_blank\">Verify your eMail</a><br><br>Thank you,<br><br>Ziddu Team", emailId, password, url); System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["emailAddress"].ToString(), emailId, "Welcome to Ziddu.com", body); //msg.Bcc.Add("*****@*****.**"); System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("31.3.223.108"); smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["emailAddress"].ToString(), ConfigurationManager.AppSettings["emailPwd"].ToString()); msg.IsBodyHtml = true; smtp.Send(msg); } catch (Exception ex) { } }
//desc = desc.Replace(" ", "<img title="Time Please" alt="clock" src="Chat/Smiley/clock.png" onclick="smiley(this,':tp');" id="11" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="cool" alt="cool" src="Chat/Smiley/cool.png" onclick="smiley(this,':cool');" id="12" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="crazy" alt="crazy" src="Chat/Smiley/crazy.png" onclick="smiley(this,':czy');" id="13" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="cry" alt="cry" src="Chat/Smiley/cry.png" onclick="smiley(this,':cry');" id="14" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="devil" alt="devil" src="Chat/Smiley/devil.png" onclick="smiley(this,':dvl');" id="15" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="blush" alt="blush" src="Chat/Smiley/blush.png" onclick="smiley(this,':blush');" id="16" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="Stop" alt="dnd" src="Chat/Smiley/dnd.png" onclick="smiley(this,':stop');" id="17" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="flower" alt="flower" src="Chat/Smiley/flower.png" onclick="smiley(this,':flwr');" id="18" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="geek" alt="geek" src="Chat/Smiley/geek.png" onclick="smiley(this,':geek');" id="20" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="gift" alt="gift" src="Chat/Smiley/gift.png" onclick="smiley(this,':gift');" id="21" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="ill" alt="ill" src="Chat/Smiley/ill.png" onclick="smiley(this,':ill');" id="22" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="in love" alt="in_love" src="Chat/Smiley/in_love.png" onclick="smiley(this,':love');" id="23" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="file" alt="text_file" src="Chat/Smiley/text_file.png" onclick="smiley(this,':file');" id="24" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="kissy" alt="kissy" src="Chat/Smiley/kissy.png" onclick="smiley(this,':kiss');" id="25" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="laugh" alt="laugh" src="Chat/Smiley/laugh.png" onclick="smiley(this,':laugh');" id="26" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="mail" alt="mail" src="Chat/Smiley/mail.png" onclick="smiley(this,':mail');" id="27" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="music2" alt="music2" src="Chat/Smiley/music2.png" onclick="smiley(this,':music');" id="28" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="Whistle" alt="not_guilty" src="Chat/Smiley/not_guilty.png" onclick="smiley(this,':whst');" id="29" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="please" alt="please" src="Chat/Smiley/please.png" onclick="smiley(this,':please');" id="30" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="info" alt="info" src="Chat/Smiley/info.png" onclick="smiley(this,':info');" id="31" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="sad" alt="sad" src="Chat/Smiley/sad.png" onclick="smiley(this,':sad');" id="32" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="silly" alt="silly" src="Chat/Smiley/silly.png" onclick="smiley(this,':silly');" id="33" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="Laugh Out Loud" alt="oh" src="Chat/Smiley/oh.png" onclick="smiley(this,':lol');" id="34" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="speechless" alt="speechless" src="Chat/Smiley/speechless.png" onclick="smiley(this,':slps');" id="35" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="surprised" alt="surprised" src="Chat/Smiley/surprised.png" onclick="smiley(this,':srpd');" id="36" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="tease" alt="tease" src="Chat/Smiley/tease.png" onclick="smiley(this,':tease');" id="37" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="wink" alt="wink" src="Chat/Smiley/wink.png" onclick="smiley(this,':wink');" id="38" style="cursor: pointer"> //desc = desc.Replace(" ", "<img title="Big Grin" alt="Big Grin" src="Chat/Smiley/xd.png" onclick="smiley(this,':grin');" id="39" style="cursor: pointer"> //string exDir = HttpContext.Current.Server.MapPath(@"Chat\Smiley"); //foreach (string exFile in Directory.GetFiles(exDir)) //{ //} public static void SendGmail(string mailTo, string commaDelimCCs, string subject, string message, bool isBodyHtml) { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("*****@*****.**", mailTo, subject, message); msg.IsBodyHtml = isBodyHtml; if (commaDelimCCs != "") { msg.Bcc.Add(commaDelimCCs); } System.Net.NetworkCredential cred = new System.Net.NetworkCredential("*****@*****.**", "hrmsedutel12"); System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); mailClient.EnableSsl = true; mailClient.UseDefaultCredentials = false; mailClient.Credentials = cred; mailClient.Send(msg); }
protected void Button3_Click(object sender, EventArgs e) { Response.Write("<script>alert('key sent successfully..')</script>"); System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); System.Net.NetworkCredential cred = new System.Net.NetworkCredential("*****@*****.**", "packtemp1234"); cmd = new SqlCommand("select * from patientreg where paid='" + DropDownList1.SelectedItem.Text + "'", con); //SqlDataAdapter ed = new SqlDataAdapter("select * from testdetail where patientidno='" + user.Text + "'", con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { //string em = dr[0].ToString(); string em = TextBox4.Text; mail.To.Add(em); mail.Subject = " Report key for patientidno'" + DropDownList1.SelectedItem.Text + "'"; mail.From = new System.Net.Mail.MailAddress("*****@*****.**"); mail.IsBodyHtml = true; // Aceptamos HTML //System.IO.StringWriter sw = new System.IO.StringWriter(); //System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); //GridView1.RenderControl(htw); //string renderedGridView = sw.ToString(); mail.Body = " patient test details '" + dr[9].ToString() + "' !!!"; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com"); smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Credentials = cred; //asignamos la credencial smtp.Send(mail); dr.Close(); cmd = new SqlCommand("insert into emergencydet values('" + TextBox1.Text + "','" + DropDownList1.SelectedItem.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "')", con); cmd.ExecuteNonQuery(); } con.Close(); //SendHTMLMail(); }
protected void Page_Load(object sender, EventArgs e) { try { XmlDocument xdom = new XmlDocument(); xdom.Load(Server.MapPath("hit.xml")); lblToplamHit.Text = xdom.ChildNodes[1].ChildNodes[0].InnerText; lblSonUye.Text = Functions.sonUyeGetir(); lblKonuSayisi.Text = Functions.ToplamKonuSayisi().ToString(); lblOnlineMisafir.Text = Application["OnlineMisafir"].ToString(); lblOnlineUye.Text = Membership.GetNumberOfUsersOnline().ToString(); lblUyeSayisi.Text = Membership.GetAllUsers().Count.ToString(); } catch (Exception ex) { try { System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); System.Net.Mail.MailAddress sndr = new System.Net.Mail.MailAddress("*****@*****.**"); System.Net.Mail.MailAddress receiver = new System.Net.Mail.MailAddress("*****@*****.**", "FyDoxaAdmin"); string ip = Request.ServerVariables["REMOTE_ADDR"].ToString(); string zaman = DateTime.Now.ToLongTimeString(); string hata = "Inner Exception"; if (Server.GetLastError().InnerException != null) { hata = Server.GetLastError().InnerException.Message; } System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(sndr, receiver); mail.Subject = "İstatistik ascx Hatası"; mail.Body = "Hata Oluşma Zamanı : " + zaman + " <br/> Ip Adresi : " + ip + " <br/> Yardımcı Link : " + Server.GetLastError().HelpLink + " <br/> Oluşan Son Hata : " + Server.GetLastError().ToString() + " <br/> Inner Exception : " + hata + " <br/> Son Oluşan Hata'nın Data Bilgisi : " + Server.GetLastError().Data.ToString() + "Exception Adı : " + ex.ToString(); mail.BodyEncoding = Encoding.Default; mail.IsBodyHtml = true; mail.Priority = System.Net.Mail.MailPriority.Normal; smtp.Send(mail); } catch (Exception) { } } }
/// <summary> /// Send a mail /// </summary> public static void SendMail(string theSubject, string theMessage, params string[] theTo) { #if UNITY_EDITOR && !UNITY_WEBPLAYER System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); for (int i = 0; i < theTo.Length; i++) { message.To.Add(theTo[i]); } message.Subject = theSubject; message.From = new System.Net.Mail.MailAddress(itsFrom); message.Body = theMessage; message.IsBodyHtml = true; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(itsSMTP); smtp.Credentials = new System.Net.NetworkCredential(itsUser, itsPass) as ICredentialsByHost; smtp.EnableSsl = true; ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; smtp.Send(message); #endif }
/// <summary> /// 发邮件 /// </summary> /// <param name="to"></param> /// <param name="title"></param> /// <param name="content"></param> /// <returns></returns> public static bool sendEmail(string to, string title, string content) { try { System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.163.com"); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "linghang"); client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", to, title, content); message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; // 允许邮件主体使用HTML message.Priority = System.Net.Mail.MailPriority.High; client.Send(message); return(true); } catch (Exception ex) { return(false); } }
public bool sendEmail(System.Net.Mail.MailMessage obMsg) { bool funValue = false; try{ System.Net.Mail.SmtpClient obSmtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); System.Net.NetworkCredential obUserInfo = new System.Net.NetworkCredential("yourEmail", "yourPassword"); obSmtp.UseDefaultCredentials = false; obSmtp.Credentials = obUserInfo; obSmtp.EnableSsl = true; obSmtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; obSmtp.Send(obMsg); obMsg = null; funValue = true; } catch (Exception ex) { funValue = false; } return(funValue); }
public void SendMail(string body, string toAddress) { var fromAddress = ConfigurationManager.AppSettings["emailRemetente"].ToString(); var fromPassword = ConfigurationManager.AppSettings["emailSenhaRemetente"].ToString(); var assunto = ConfigurationManager.AppSettings["emailAssunto"].ToString(); var smtpServer = ConfigurationManager.AppSettings["emailSMTPServer"].ToString(); int smtpPort = int.Parse(ConfigurationManager.AppSettings["emailSMTPPort"]); var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = smtpServer; smtp.Port = smtpPort; smtp.EnableSsl = false; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = 20000; } smtp.Send(fromAddress, toAddress, assunto, body); }
private void SendMail(int zid, string gid) { try { string stmt = string.Format("SELECT email FROM ziddumembers WHERE zid = '{0}';", zid); DataSet ds = MySQLHelper.ExecuteDataset(connectionString, stmt); if (ds != null && ds.Tables[0].Rows.Count > 0) { string url = string.Format(ConfigurationManager.AppSettings["mailPath"].ToString() + "tverify.aspx"); string body = string.Format("Dear Ziddu Member,<br><br>This alert was generated to notify you of recent transaction on your account.<br><br>For security reasons, We have temporarily put a hold on the transaction until necessary verification is done. You are to sign on and verify your account. Payment will be posted same day after your verification.<br><br>Verification Code : {0}<br><br><a href='{1}' target='_blank'>VERIFY TO APPROVE YOUR TRANSACTION</a><br><br>Thank you,<br><br>Ziddu Team", gid, url); System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["emailAddress"].ToString(), ds.Tables[0].Rows[0]["email"].ToString(), "Ziddu Transaction Notification", body); System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("31.3.223.108"); smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["emailAddress"].ToString(), ConfigurationManager.AppSettings["emailPwd"].ToString()); msg.IsBodyHtml = true; smtp.Send(msg); } } catch (Exception ex) { } }
public void SendMail() { System.Net.Mail.MailMessage MyMail = new System.Net.Mail.MailMessage(); MyMail.From = new System.Net.Mail.MailAddress("*****@*****.**"); MyMail.To.Add("*****@*****.**"); //設定收件者Email MyMail.Subject = "Email Test"; MyMail.Body = File.ReadAllText("result.html"); //設定信件內容 MyMail.IsBodyHtml = true; //是否使用html格式 System.Net.Mail.SmtpClient MySMTP = new System.Net.Mail.SmtpClient("smtp.hinet.net"); MySMTP.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory; MySMTP.PickupDirectoryLocation = AppDomain.CurrentDomain.BaseDirectory; try { MySMTP.Send(MyMail); MyMail.Dispose(); //釋放資源 } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void SendMail() { try{ Stringqueja = Squeja.text; if (Semail.text.Length > 0) { if (Stringqueja.Length > 0) { System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage(); email.To.Add(Semail.text); email.Subject = "Solicitud de Soporte Tecnico"; email.SubjectEncoding = System.Text.Encoding.UTF8; email.Body = "Solicitud de Soporte Tecnico." + "\nDecripcion de queja: " + Stringqueja + "." + "\nSu queja sera revisada por los desarrolladores." + "\nPuede responder a este correo."; email.BodyEncoding = System.Text.Encoding.UTF8; email.From = new System.Net.Mail.MailAddress("*****@*****.**"); System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient(); cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "MockGames"); cliente.Port = 587; cliente.EnableSsl = true; cliente.Host = "smtp.gmail.com"; cliente.Send(email); lblMsg.text = "Se envio un correo para revisar su Queja."; } else { lblMsg.text = "Debe ingresar una descripción."; } } else { lblMsg.text = "Debe ingresar una direccion de correo electronico."; } }catch (UnityException ex) { lblMsg.text = "Error: " + ex.Message; } }
protected void Button1_Click(object sender, EventArgs e) { count(); Data(); str_allergens = str_allergens.TrimEnd(','); email2 = str_allergens.Split(','); for (int i = 0; i < rows; i++) { System.Net.Mail.SmtpClient MySmtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); //設定你的帳號密碼 MySmtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "boy37201"); //Gmial 的 smtp 必需要使用 SSL MySmtp.EnableSsl = true; //發送Email MySmtp.Send("*****@*****.**", email2[i], "寵物廚房", TextBox3.Text); MySmtp.Dispose(); } Response.Redirect("/webs/manager/backmanagersearchcustomer.aspx"); }
public void EnviarCorreo(string para, string asunto, string mensaje) { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.To.Add(para); //para saber a quien se lo enviamos msg.Subject = asunto; // el asunto msg.SubjectEncoding = System.Text.Encoding.UTF8; msg.Body = mensaje; //el mensaje msg.BodyEncoding = System.Text.Encoding.UTF8; msg.IsBodyHtml = true; msg.From = new System.Net.Mail.MailAddress("*****@*****.**"); //desde donde se envia el correo System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient(); cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "uceva2024"); //credenciales cliente.Port = 587; cliente.EnableSsl = true; cliente.Host = "smtp.gmail.com"; try{ cliente.Send(msg); } catch (Exception ex) { Response.Write("Error al enviar correo: " + ex.StackTrace); } }
protected void Button1_Click(object sender, EventArgs e) { Random rnd = new Random(); int otp = rnd.Next(123456780); // Gmail Address from where you send the mail var fromAddress = "*****@*****.**"; // any address where the email will be sending var toAddress = txtUser.Text; //Password of your gmail address const string fromPassword = "******"; // Passing the values and make a email formate to display string subject = "Welcome to OTP Generation"; string body = "OTP: " + otp + "\n"; body += "Date: " + System.DateTime.Now.ToShortDateString() + "\n"; body += "Time: " + System.DateTime.Now.ToShortTimeString() + "\n"; body += "Description: \n" + "Valid Upto This Session" + "\n"; // smtp settings var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = 20000; } // Passing values to smtp object smtp.Send(fromAddress, toAddress, subject, body); con.open_connection(); String st = "update registration set password='******' where emailID='" + txtUser.Text + "' "; SqlCommand cmd = new SqlCommand(st, con.con_pass()); cmd.ExecuteNonQuery(); con.close_connection(); Response.Write("<script>alert('OTP Send to Your Gmail ID') </script>"); Response.Redirect("Login2.aspx?email=" + txtUser.Text); }
/// <summary> /// 用户注册之后,给用户发的激活账户的邮件 /// </summary> /// <param name="userEntity">用户实体</param> /// <returns>成功发送邮件</returns> public static bool AfterUserRegister(PiUserEntity userEntity) { bool returnValue = false; IDbProvider dbProvider = new SqlProvider(RDIFrameworkDbConection); UserInfo userInfo = null; try { using (var mailMessage = new System.Net.Mail.MailMessage()) { // 接收人邮箱地址 mailMessage.To.Add(new System.Net.Mail.MailAddress(userEntity.Email)); mailMessage.Body = GetAfterUserRegisterBody(userEntity); mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "新密码"); mailMessage.BodyEncoding = Encoding.GetEncoding("GB2312"); mailMessage.Subject = "新密码。"; mailMessage.IsBodyHtml = true; var smtpclient = new System.Net.Mail.SmtpClient(SystemInfo.ErrorReportMailServer) { Credentials = new System.Net.NetworkCredential(SystemInfo.ErrorReportMailUserName, SystemInfo.ErrorReportMailPassword), EnableSsl = false }; smtpclient.Send(mailMessage); returnValue = true; } } catch (System.Exception exception) { // 若有异常,应该需要保存异常信息 CiExceptionManager.LogException(dbProvider, userInfo, exception); returnValue = false; } finally { dbProvider.Close(); } return(returnValue); }
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents': //ORIGINAL LINE: Protected Sub GridView1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging protected void GridView1_SelectedIndexChanging(object sender, System.Web.UI.WebControls.GridViewSelectEventArgs e) { string id = GridView1.DataKeys[e.NewSelectedIndex].Values[0].ToString(); string Pass = ""; DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider(); Pass = data.ForgotPassword(id); Pass = System.Text.Encoding.Default.GetString(Convert.FromBase64String(Pass)); try { using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["AdminEmail"], GridView1.Rows[e.NewSelectedIndex].Cells[2].Text, "Your password for the Guestbook", "Your password is: " + Pass)) { System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings["MailServer"]); smtp.Send(mail); } } catch (Exception ex) { DisplayError(ex.Message); } }
public static void EnvioActualizacionExamenMedico(string body, List <string> mailDestino, string MailOrigen, string sSujeto, string SMTPMailOrigen, string UsuarioMailOrigen, string ClaveMailOrigen) { try { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); foreach (var item in mailDestino) { msg.To.Add(new System.Net.Mail.MailAddress(item)); } msg.From = new System.Net.Mail.MailAddress(MailOrigen); msg.CC.Add(new System.Net.Mail.MailAddress("*****@*****.**")); msg.Subject = sSujeto; msg.Body = body; msg.IsBodyHtml = true; System.Net.Mail.SmtpClient clienteSmtp = new System.Net.Mail.SmtpClient(SMTPMailOrigen); clienteSmtp.Credentials = new System.Net.NetworkCredential(UsuarioMailOrigen, ClaveMailOrigen); clienteSmtp.Send(msg); } catch { } }
/// <summary> /// sending email , subject is title of email, body is the content, FromName is the name of who send email /// </summary> /// <param name="Email"></param> /// <param name="Subject"></param> /// <param name="Body"></param> /// <param name="FromName"></param> public static void SendMail(string EmailTo, string Subject, string Body, string FromName) { // Gmail Address from where you send the mail // default [email protected] | pass Capsole1@ | Host mail.iris.arvixe.com | port 25 // from source email to send string FromAddress = WebConfigurationManager.AppSettings["Email_ID"].ToString(); string FromPassword = WebConfigurationManager.AppSettings["Email_Pass"].ToString(); System.Net.Mail.MailMessage eMail = new System.Net.Mail.MailMessage(); eMail.IsBodyHtml = true; eMail.Body = Body; eMail.From = new System.Net.Mail.MailAddress(FromAddress, FromName); eMail.To.Add(EmailTo); eMail.Subject = Subject; System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient(); SMTP.Credentials = new System.Net.NetworkCredential(FromAddress, FromPassword); SMTP.Host = WebConfigurationManager.AppSettings["Email_Host"]; SMTP.Send(eMail); }
protected void SendMail() { if (txtEmail.Value != "") { Random rand = new Random((int)DateTime.Now.Ticks); cls_security md5 = new cls_security(); int numIterations = 12345; //numIterations = rand.Next(1, 100000); admin_User update = (from u in db.admin_Users where u.username_email == txtEmail.Value select u).SingleOrDefault(); update.username_password = md5.HashCode(numIterations.ToString()); //update.username_password =numIterations.ToString(); db.SubmitChanges(); var fromAddress = "*****@*****.**"; // [email protected] // pass : abc123#! var toAddress = txtEmail.Value; // const string fromPassword = "******"; //Password of your Email address jcstiaveptusqrxm string subject = "Mật khẩu mới của admin"; string body = "Mật khẩu mới để vào lại website quản trị : " + numIterations.ToString(); var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = 20000; } smtp.Send(fromAddress, toAddress, subject, body); //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "AlertBox", "swal('Thành công', 'Vui lòng check mail để xác nhận mật khẩu mới','success').then(function(){window.location = '/admin-login';})", true); alert.alert_Success(Page, "Thành công", "Vui lòng check mail để xác nhận mật khẩu mới"); } else { //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "AlertBox", "swal('Lỗi', 'Vui lòng kiểm trả lại email','error').then(function(){window.location = '/admin-login';})", true); alert.alert_Error(Page, "Lỗi", "Vui lòng kiểm tra lại email"); } }
public static string SendEmail(string To, string from, string subject, string body, string host, int port) { string result = "NOT SENT."; try { System.Net.Mail.SmtpClient mc = new System.Net.Mail.SmtpClient(host, port); System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(from, To, subject, body); string userid; string password; userid = ConfigurationManager.AppSettings["userid"].ToString(); password = ConfigurationManager.AppSettings["password"].ToString(); mc.Credentials = new System.Net.NetworkCredential(userid, password); msg.IsBodyHtml = true; mc.Send(msg); result = "SENT."; } catch (Exception ex) { result = ex.Message; //throw; } return(result); }
public void enviarCorreo(string origen, string destino, string copiaoculta, string asunto, string mensaje) { System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage(); correo.From = new System.Net.Mail.MailAddress(origen); correo.To.Add(destino); if (copiaoculta != "-") { correo.Bcc.Add(copiaoculta); } correo.Subject = asunto; correo.Body = mensaje; correo.IsBodyHtml = true; correo.Priority = System.Net.Mail.MailPriority.Normal; correo.BodyEncoding = System.Text.Encoding.UTF8; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); smtp.Host = "smtp.cibnor.mx"; smtp.Send(correo); }
public bool SendMail(string mailTo, string subject) { System.Net.Mail.MailMessage mailmessage = new System.Net.Mail.MailMessage("*****@*****.**", mailTo); System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Blaatschaap10"); // Mail configuratie even uitgezet ivm fouten in mail //smtp.Host = "ex2013.csg-comenius.nl"; //smtp.Port = 578; smtp.EnableSsl = true; mailmessage.Subject = subject; mailmessage.IsBodyHtml = true; mailmessage.Body = msgBody; /*string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); * string path = Path.Combine(dir, "test.txt"); * mailmessage.Attachments.Add(new System.Net.Mail.Attachment(path));*/ try{ smtp.Send(mailmessage); return(true); } catch { return(false); } }
public static void SendEmail(string From, string Recipients, string Subject, string Body) { System.Net.Mail.SmtpClient objMail = new System.Net.Mail.SmtpClient(""); objMail.Send(From, Recipients, Subject, Body); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { int x = Int32.Parse(lblAccountNo.Text); var data = db.MAccounts.Where(d => d.AccountNo == x).FirstOrDefault(); if (data != null) { if (CheckBox1.Checked) { data.Status = "Approved"; } else { data.Status = "Not Approved"; } db.SaveChanges(); System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); if (data != null) { mail.To.Add(data.User.Email); mail.From = new System.Net.Mail.MailAddress("*****@*****.**", "Anis", System.Text.Encoding.UTF8); mail.Subject = "Approval"; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = "Dear " + data.UserName + "Account is approved"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = System.Net.Mail.MailPriority.High; System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "round-27"); client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; try { client.Send(mail); ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent')", true); } catch (Exception ex) { Literal1.Text = ex.Message; } } ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Update Successfully!!!')", true); lblAccountNo.Text = ""; lblStartDate.Text = ""; CheckBox1.Text = ""; lblMemberName.Text = ""; } } catch (Exception ex1) { Literal1.Text = ex1.Message; } }
protected static void SimpleEmail(string from_address, string from_name, string to, string subject, string body, bool isHTML, string smtp_host, int smtp_port, string accountUsername, string accountPassword, string[] attachments, System.Net.Mail.AlternateView[] alternativeViews) { if (isHTML && to.Contains(ConfigurationManager.AppSettings["EmailStringMatchToConvertToPlainText"])) { body = HtmlConverter.HTMLToText(body); isHTML = false; } System.Net.Mail.Attachment[] list = null; try { System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.From = new System.Net.Mail.MailAddress(from_address, from_name); foreach (string _to in to.Split(',')) { message.To.Add(_to.Trim()); } message.Subject = subject; message.Body = body; message.IsBodyHtml = isHTML; if (alternativeViews != null) { for (int i = 0; i < alternativeViews.Length; i++) { message.AlternateViews.Add(alternativeViews[i]); } } if (attachments != null && attachments.Length > 0) { list = new System.Net.Mail.Attachment[attachments.Length]; for (int i = 0; i < attachments.Length; i++) { list[i] = new System.Net.Mail.Attachment(attachments[i]); message.Attachments.Add(list[i]); } } System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smtp_host, smtp_port); if (accountUsername.Length > 0 || accountPassword.Length > 0) { smtp.Credentials = new System.Net.NetworkCredential(accountUsername, accountPassword); } else { smtp.UseDefaultCredentials = false; // turn off validating certificate because it is throwing an error when using anonymous sending System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificates.X509Certificate certificate, X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return(true); }; } smtp.Timeout = 300000; // 300 sec = 5 mins smtp.EnableSsl = true; smtp.Send(message); } catch (Exception ex) { Logger.LogException(ex, false); // cant email it again if emailing is failing.. } finally { // unlock the files they reference if (list != null) { for (int i = 0; i < list.Length; i++) { list[i].Dispose(); } } } }
private bool EnviarCorreo(string correoEnviar, string usuariohost, string contrasena, int puerto, int ssl, string host, string mensaje, string contraseña, string asunto, ListBox adjuntos, string CC, string CCO) { bool envio = false; /*-------------------------MENSAJE DE CORREO----------------------*/ //Creamos un nuevo Objeto de mensaje System.Net.Mail.MailMessage mmsg = new System.Net.Mail.MailMessage(); //Direccion de correo electronico a la que queremos enviar el mensaje mmsg.To.Add(correoEnviar); //Nota: La propiedad To es una colección que permite enviar el mensaje a más de un destinatario //Asunto mmsg.Subject = asunto;// "Asunto del correo"; mmsg.SubjectEncoding = System.Text.Encoding.UTF8; if (CC != "") { mmsg.CC.Add(CC); } if (CCO != "") { mmsg.Bcc.Add(CCO); } //Cuerpo del Mensaje mmsg.Body = mensaje;//Texto del contenio del mensaje de correo if (adjuntos != null) { //Adjuntos foreach (ListItem l in adjuntos.Items) { mmsg.Attachments.Add(new System.Net.Mail.Attachment(l.Value)); } } mmsg.BodyEncoding = System.Text.Encoding.UTF8; mmsg.IsBodyHtml = true; //Si no queremos que se envíe como HTML //Correo electronico desde la que enviamos el mensaje mmsg.From = new System.Net.Mail.MailAddress(usuariohost); //"*****@*****.**");//"*****@*****.**"); /*-------------------------CLIENTE DE CORREO----------------------*/ //Creamos un objeto de cliente de correo System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient(); //Hay que crear las credenciales del correo emisor cliente.Credentials = new System.Net.NetworkCredential(usuariohost, contrasena);//"*****@*****.**", "juanFS2014");//"*****@*****.**", "micontraseña"); //Lo siguiente es obligatorio si enviamos el mensaje desde Gmail ///* cliente.Port = puerto; bool ssl_obtenido = false; if (ssl == 1) { ssl_obtenido = true; } cliente.EnableSsl = ssl_obtenido; //*/ cliente.Host = host; //"mail.formulasistemas.com";// "mail.servidordominio.com"; //Para Gmail "smtp.gmail.com"; /*-------------------------ENVIO DE CORREO----------------------*/ try { //Enviamos el mensaje cliente.Send(mmsg); envio = true; } catch (System.Net.Mail.SmtpException ex) { envio = false;//Aquí gestionamos los errores al intentar enviar el correo } return(envio); }
protected void btn_send_Click(object sender, EventArgs e) { if (conn.State == ConnectionState.Closed) { conn.Open(); } try { // here in SqlDataAdapter i am executing sql query if after the execution of this query there will be any data inside the datatable then // execute the else condition. otherwise it enter in the if condition and display message "Enter valid email address or uname". // in the below query i am checking uname and email address entered by the user with the values inside the database adp = new SqlDataAdapter("select Username,Email from Registrationtb where Email=@Email or Username=@Username", conn); //here a i am passing parameter named email from the txt_email.Text's value adp.SelectCommand.Parameters.AddWithValue("@Email", txt_email.Text); //here a i am passing parameter named uname from the txt_uname.Text's value adp.SelectCommand.Parameters.AddWithValue("@Username", txt_uname.Text); dt = new DataTable(); adp.Fill(dt); if (dt.Rows.Count == 0) { lbl_msg.Text = "Enter valid email address or uname"; txt_email.Text = ""; txt_uname.Text = ""; return; } else { // if the values entered by the user will be correct then this code will execute. // below inside the code variable i am catching the autogenerated value which will different evertime. string code; code = Guid.NewGuid().ToString(); // and am updating the code column of the table with this value. i mean inside the code column i'll store the value // that was inside the code variable cmd = new SqlCommand("update Registrationtb set code=@code where Email=@email or Username=@Username", conn); cmd.Parameters.AddWithValue("@code", code); cmd.Parameters.AddWithValue("@Email", txt_email.Text); cmd.Parameters.AddWithValue("@Username", txt_uname.Text); // here i am difinning a StringBuilder class named sbody StringBuilder sbody = new StringBuilder(); // here i am sending a link to the user's mail address with the three values email,code,uname // these three values i am sending this link with the values using querystring method. sbody.Append("<a href=http://localhost:2175/CreatePassword.aspx?Email=" + txt_email.Text); sbody.Append("&code=" + code + "&Username="******">Click here to change your password</a>"); //in the below line i am sending mail with the link to the user. //in this line i am passing four parameters 1st sender's mail address ,2nd receiever mail address, 3rd Subject,4th sbody.ToString() there will be complete link // inside the sbody System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage("*****@*****.**", dt.Rows[0]["Email"].ToString(), "Reset Your Password", sbody.ToString()); mail.CC.Add("*****@*****.**"); //in the below i am declaring the receiever email address and password System.Net.NetworkCredential mailAuthenticaion = new System.Net.NetworkCredential("[email protected] ", "kaushal007"); // in the below i am declaring the smtp address of gmail and port number of the gmail System.Net.Mail.SmtpClient mailclient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); mailclient.EnableSsl = true; mailclient.Credentials = mailAuthenticaion; // here am setting the property IsBodyHtml true because i am using html tags inside the mail's code mail.IsBodyHtml = true; mailclient.Send(mail); cmd.ExecuteNonQuery(); cmd.Dispose(); conn.Close(); lbl_msg.Text = "Link has been sent to your email address"; txt_email.Text = ""; txt_uname.Text = ""; } } catch (Exception ex) { // if there will be any error created at the time of the sending mail then it goes inside the catch //and display the error in the label lbl_msg.Text = ex.Message; } finally { conn.Close(); } }
protected void ButtonCheckOut_Click(object sender, EventArgs e) { if (LabelGtotal.Text == "0") { LabelOrderSuccess.Text = "<p style='color:blue; font-size: 20px;'>" + "no item to order!" + "</p>"; return; } else { Order ord = new Order(); ord.OrderDate = DateTime.Now.Date; ord.GranTotal = decimal.Parse(LabelGtotal.Text); ord.CustomerId = Int32.Parse(Session["uid"].ToString()); ord.DeliveryStatus = "Pending"; db.Orders.Add(ord); db.SaveChanges(); OrderDetail ordetails = new OrderDetail(); for (int i = 0; i < dt.Rows.Count; i++) { ordetails.OrderId = ord.Id; ordetails.ProductId = Int32.Parse(dt.Rows[i][0].ToString()); ordetails.Quantity = Int32.Parse(dt.Rows[i][3].ToString()); ordetails.Price = decimal.Parse(dt.Rows[i][4].ToString()); ordetails.Total = decimal.Parse(dt.Rows[i][5].ToString()); System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add("*****@*****.**"); mail.From = new System.Net.Mail.MailAddress("*****@*****.**", "Admin", System.Text.Encoding.UTF8);//"*****@*****.**", "Admin" mail.Subject = "New order!"; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = "<p style='color:red; font-size: 50px;'>" + "New order has arrive!" + "</p>"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = System.Net.Mail.MailPriority.High; System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "retroelectro112233"); //"*****@*****.**", "round-27" client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; try { client.Send(mail); ClientScript.RegisterStartupScript(GetType(), "alert", "alert: ('email sent successfully!')"); } catch (Exception ex) { LabelCustomerEmail.Text = ex.Message; } System.Threading.Thread.Sleep(3000); LabelOrderSuccess.Text = "<p style='color:green; font-size: 50px;'>" + "your order has process successfully! please check your RE account!" + "</p>"; db.OrderDetails.Add(ordetails); db.SaveChanges(); } Session["dt"] = null; dt = (DataTable)Session["dt"]; //Label lbl_UserName = this.Master.FindControl("LabelCart") as Label; //lbl_UserName.Text = Session["dt"].ToString(); GridView1.DataSource = dt; GridView1.DataBind(); } }