hi all, I'm facing a problem and I need an urgent help please, I can not send any email instead i the debugging mode the parser goes through the function without error! I have read the KB here and other articles too but doesn't work here is my function: Protected Sub sendEmail() Dim message As New MailMessage() Dim smtpClient1 As New SmtpClient() Dim fromAdrs As New MailAddress("[email protected]", "CMC course registration") Dim toAdrs As New MailAddress(txtEmailaddr.Text, txtName.Text) message.To.Add(toAdrs) message.Bcc.Add("[email protected]") message.From = fromAdrs message.Subject = "Successfully course registered" message.Body = "test" message.IsBodyHtml = True smtpClient1.Host = "localhost" smtpClient1.Send(message) End Sub there is no runtime error, but No emails sent !! Thanks
You may be missing the System.Net.Mail import or the web.config settings, or both. Scott Guthrie has a good blog post about System.Net.Mail in asp.net 2: http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx For DASP accounts the section in your web.config would look like this: <system.net> <mailSettings> <smtp> <network host="localhost" port="25"/> </smtp> </mailSettings> </system.net>
Thank you wisemxfor your response, frankly I don't know what to say but it doesn't work this is my code function Protected Sub sendEmail() Dim message As New MailMessage() Dim smtpClient1 As New SmtpClient() Dim fromAdrs As New MailAddress("[email protected]", "CMC course registration") Dim toAdrs As New MailAddress(txtEmail.Text, txtName.Text) message.To.Add(toAdrs) message.Bcc.Add(txtEmail.Text) message.From = fromAdrs message.Subject = "Successfully course registered" message.Body = "test msg" message.IsBodyHtml = True smtpClient1.Host = "localhost" smtpClient1.Port = 25 smtpClient1.Send(message) End Sub I think there is no need to add the smtp in web.config if it is written in the function (host & port) as above I read the scott blog too your help is highly appreciated
Can we see more of that code? (To help you.) i.e., where the input values are passed and when. You may be missing the actual event, which can not be diagnosed at this point without the remaining code sections.
Another potential problem is Bare LF in your email message. IIS SMTP will NOT deliver email w/ Bare LF in the message body. if you still have trouble, create a ticket w/ the From / To address and we can look at the SMTP log to see what happened to the message. Bruce DiscountASP.NET www.DiscountASP.NET
Thanks all for your response, it doesn't work I'm sorry Bruce if you could explain to me more about the "w/ Bare LF" and what to do exactly... Acctually there is aprocedurenamed sendEmail()called when I hit the submit button... kindly see the test.aspx page on www.cmc-training.com/test.aspx regards,
See http://kb.discountasp.net/article.aspx?id=10185for more technical explaination on this. Also open a support ticket for em to check the mail queue. The mail could have been delivered but was trapped by the spam filter. Bruce DiscountASP.NET www.DiscountASP.NET