Click here to Skip to main content
15,888,058 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to send out an email after a button click event. When testing from my local machine everything runs smooth, the email get send out and I get the popup message notifying me that the "call has been resolved". But running from server side the page "hangs" - the screen is dimmed out which should happen until the email is sent off, but it stays like that. the email does not get sent out from server side....

C#
  MailMessage Mail = new MailMessage();
        Mail.Subject = "Call Resolved";
        Mail.To.Add(useremail);
        //  Mail.To.Add(useremail);
        Mail.From = new MailAddress("notifications@oep.co.za");

        string path = PopulateEmailImage();

        LinkedResource logo = new LinkedResource(path);
        logo.ContentId = "header";

        AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><head>" +
                            @"<meta content=""text/html; charset=utf-8"" http-equiv=""Content-Type""/> " +
                            @"<title></title></head><body ><style> " +
                        @".auto-style1 {width: 188px; }table tr td{ border:solid;border-width:1px;} .link{color:red;}</style> " +
                        @"<img alt="""" height=""130"" src=""cid:header"" width=""675"" /> " +
                        @"<div style=""color:red; font-weight:bold; text-align:left; border:none; margin-right:20%;"" > " +
                        @"<h3>This message is sent on behalf of <br /> The Business Connexion Global Service Management Centre</h3> " +
                        @"<h5>Please do not respond to the sender as this mailbox does not receive return mail. <br /> " +
                        @"Use the Link located at the bottom of the e-mail to Respond </h5> </div><br />" +
                        @"<div>Dear " + CustName + "</div><br /> " +
                        @"<div>We are pleased to inform you that your reported Incident " + incidentNo + ", has been resolved. </div><br /> " +
                        @"<div>Incident Summary report as follows:</div> <br /> " +
                        @"<table style=""width:45%; border:solid; border-width:3px; background-color:#E2E2E2;""> " +
                        @"<tr><td class=""auto-style1"">Incident Number:</td><td>" + incidentNo + "</td> " +
                        @"<tr><td class=""auto-style1"">Status:</td><td>" + stats + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">CI Serial No:</td><td>" + serialNo + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">Incident Summary:</td><td>" + incidentSum + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">Incident Notes:</td><td>" + incidentNotes + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">Resolution:</td><td>" + resolution + "</td></tr> " +
                        @"</table><br /><div> " +
                        @"If you have any queries or if you would like to change your contact details, please contact the <br /> Global Service Management Centre. " +
                        @"</div><br /><div> " +
                        @"<a href=""spoc@bcx.co.za"" class=""link"">Click here if you would like to contact the Global Service Management Centre via e-mail</a> </div> " +
                        @"<br /><div>011 266 1102 (National, South African number) <br />+27 (0) 266 1102 (International number)<br /> " +
                        @"E-mail queries to <a href=""spoc@bcx.co.za"" class=""link"">spoc@bcx.co.za</a> <br /></div><br /><div>Yours in service <br /> " +
                        @"Global Service Management Centre</div></body></html>", null, MediaTypeNames.Text.Html);

        av1.LinkedResources.Add(logo);
        Mail.AlternateViews.Add(av1);

        System.Configuration.Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("~/web.config");
        MailSettingsSectionGroup mailSettings = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
        if (mailSettings != null)
        {
            int port = mailSettings.Smtp.Network.Port;
            string host = mailSettings.Smtp.Network.Host;
            string password = mailSettings.Smtp.Network.Password;
            string username = mailSettings.Smtp.Network.UserName;
        }
        SmtpClient SMTP = new SmtpClient();
        SMTP.Send(Mail);

<mailSettings>
  <smtp deliveryMethod="Network" from="Notifications@office.co.za">
    <network host="ipAddress" userName="notifications@oep.co.za" password="password" port="25" />
  </smtp>
</mailSettings>


The EnalbleSSl has been set to false and true - neither works. I have used telnet to check if I can connect to the ip and port - both is fine... Any help will be greatly appreciated! There are no firewalls that is blocking the email from sending out either.
Posted

1 solution

Add try catch block may be getting some exception during smtp.send request
 
Share this answer
 
Comments
link_that 20-Feb-14 6:02am    
Not receiving any errors through the try catch or debug... On local it works fine though....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900