|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problems with System.Net.MailI have written some very simple code that runs within my website that use system.web.mail to send an email using the SMTP server here. It works fine. However when I alter the code to work using system.net.mail instead and put the code in a VB.NET class library it no longer works. It does not raise an exception though. The mail just does not get sent. Does anyone have an idea as to why this might be? Hers the code that does not work: Dim oMsg As MailMessage = New MailMessage Dim oAdd As MailAddress Dim SmtpMail As SmtpClient = New SmtpClient(SMTP_SERVER) 'Create email notification oMsg.From = New MailAddress(ATLS_EMAIL) oAdd = New MailAddress(***@me.com") oMsg.To.Add(oAdd) oMsg.Subject = "whatever" 'TODO - put name in here of location manager oMsg.Body = "stuf...." SmtpMail.Send(oMsg) Heres the code that does work: Dim oMsg As MailMessage = New MailMessage() oMsg.From = AppSettings("ATLS_EMAIL") oMsg.To = "m*@me.com" oMsg.Subject = "whatever" oMsg.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = AppSettings("SMTP_SERVER") SmtpMail.Send(oMsg) There's code differences between sending mail with
system.web.mail and sending mail with system.net.mail. For complete examples using system.net.mail, see : http://www.systemnetmail.com/ Juan T. Llibre, asp.net MVP aspnetfaq.com : http://www.aspnetfaq.com/ asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ =================================== Show quoteHide quote "Proteus" <proteusduxb***@gmail.com> wrote in message news:1157492400.959244.36950@e3g2000cwe.googlegroups.com... > Hi, > > I have written some very simple code that runs within my website that > use system.web.mail to send an email using the SMTP server here. It > works fine. However when I alter the code to work using system.net.mail > instead and put the code in a VB.NET class library it no longer works. > It does not raise an exception though. The mail just does not get sent. > > Does anyone have an idea as to why this might be? Hers the code that > does not work: > > Dim oMsg As MailMessage = New MailMessage > Dim oAdd As MailAddress > Dim SmtpMail As SmtpClient = New > SmtpClient(SMTP_SERVER) > > 'Create email notification > oMsg.From = New MailAddress(ATLS_EMAIL) > oAdd = New MailAddress(***@me.com") > oMsg.To.Add(oAdd) > oMsg.Subject = "whatever" > > 'TODO - put name in here of location manager > oMsg.Body = "stuf...." > > SmtpMail.Send(oMsg) > > Heres the code that does work: > > Dim oMsg As MailMessage = New MailMessage() > oMsg.From = AppSettings("ATLS_EMAIL") > oMsg.To = "m*@me.com" > oMsg.Subject = "whatever" > oMsg.BodyFormat = MailFormat.Html > SmtpMail.SmtpServer = AppSettings("SMTP_SERVER") > SmtpMail.Send(oMsg) >
Other interesting topics
.NET 2005
Master Page prevents using style sheets? Problem with RaiseCallbackEvent wildcard mapping Delayed Code Execution? 'Could not load file or assembly' every few days - asp.net 1.1 Security exception with impersonate true for a webservice Help debugging...where do I look? making sure page loads Managing Database Connections! |
|||||||||||||||||||||||