magesh babu

magesh babu

  • NA
  • 3
  • 3.7k

Mail Not sent to Distribution List Mail ID in asp.net 3.5

Jun 22 2011 8:04 AM
Hi EveryBody!

Here i display my Code . And Waiting for ur  Quick Reply....! Pls help Me

using System.Web.Mail;
public void SendEmail(string strQry, string StackTrace)
        {
            string Toid = string.Empty;
            string strCompanyCode = HttpContext.Current.Session["Comp_Code"].ToString();
            string strUserCode = HttpContext.Current.Session["User_Code"].ToString();
            string strURL = HttpContext.Current.Request.Url.AbsoluteUri;
            string strCurrentTime = DateTime.Now.ToString();
            string strSubjectNew = "<html><body><font><b>Dear SwaaS Dev Team ,</b></font><br><br><b>New Bug has been Raised</b><br><br><font><b>URL :</b></font>" + strURL + "<br><br><font><b>Company Code :</b></font> " + strCompanyCode + "<br><br><font><b>User Code : </b> </font>" + strUserCode + "<br><br><font><b> Time: </b> </font>" + strCurrentTime + "<br><br><font><b>Query:</b></font> " + strQry + "<br><br><font><b>Exception Message:</b></font> " + StackTrace + "<br></font></body></html>";
            string server = ConfigurationSettings.AppSettings["SMTPSERVER"];
            string frommail = ConfigurationSettings.AppSettings["FROMMAIL"];
            string toMail = ConfigurationSettings.AppSettings["TOMAIL"];


            if (string.IsNullOrEmpty(toMail))
            {
                toMail = "[email protected]";
            }
            System.Web.Mail.MailMessage msgmail = new System.Web.Mail.MailMessage();
            MailMessage msgMail = new MailMessage();
            msgMail.To = Toid;
            msgMail.From = frommail;
            msgMail.To = toMail;
            msgMail.Subject = "Query Exception : Company Code : '" + strCompanyCode + "' , User Code : '" + strUserCode + "'";
            msgMail.BodyFormat = MailFormat.Html;
            msgMail.Body = strSubjectNew;
            if (server != "")
            {
               System.Web.Mail.SmtpMail.SmtpServer = server;
            }
            try
            {
                System.Web.Mail.SmtpMail.Send(msgMail);
            }
            catch (Exception ex)
            {
                throw (ex);
            }

Answers (2)