2
Answers

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

Photo of magesh babu

magesh babu

13y
3.5k
1
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 = "codingdebug@swaas.net";
            }
            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)

1
Photo of Muralidharan Deenathayalan
NA 11.9k 1.5m 13y

Are you able to send email to the Distribution List (DL) from Outlook by using your SMTP server details?
Are you getting any errors ?
Does the SMTPServer is locally configured ?If so, did you checked the log details?

0
Photo of magesh babu
NA 3 3.5k 13y
yes ! I configured Locally .And also i check the log details.it doesnt shows any error Report...When i send single user mail ID . Its sent Mail to that particular Mail ID. Problem Occurs only for Distribution mail List Only