<appsettings> <add key="SMTP" value="my SMTP" /> <add key="FROMEMAIL" value="myEmail address" /> <add key="FROMPWD" value="pwd" /> <add key="PORT" value="25" /> </appsettings>
try { string mFrom = From.ToString().Trim(); string mTo = To.ToString().Trim(); string mSubject = Subj.ToString().Trim(); string mMsg = Msg.ToString().Trim(); string mMailServer = ConfigurationManager.AppSettings.Get("SMTP"); int mPort = Convert.ToInt32(ConfigurationManager.AppSettings.Get("PORT")); MailMessage message = new MailMessage(mFrom, mTo, mSubject, mMsg); SmtpClient mySmtpClient = new SmtpClient(mMailServer, mPort); if (Bcc != "") { message.Bcc.Add(Bcc); } // mySmtpClient.Credentials = new // System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], // ConfigurationManager.AppSettings["FROMPWD"]); //mySmtpClient.EnableSsl = true; message.Priority = MailPriority.High; message.IsBodyHtml = false; mySmtpClient.UseDefaultCredentials = true; mySmtpClient.Send(message); return true; } catch (Exception ex) { return false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)