Home All Groups Group Topic Archive Search About

Problems with System.Net.Mail

Author
5 Sep 2006 9:40 PM
Proteus
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)

Author
5 Sep 2006 9:48 PM
Juan T. Llibre
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)
>

Bookmark and Share