By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,805 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,805 IT Pros & Developers. It's quick & easy.

Problems with System.Net.Mail

P: n/a
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@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 = "me@me.com"
oMsg.Subject = "whatever"
oMsg.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = AppSettings("SMTP_SERVER")
SmtpMail.Send(oMsg)

Sep 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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/
===================================
"Proteus" <pr************@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.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@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 = "me@me.com"
oMsg.Subject = "whatever"
oMsg.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = AppSettings("SMTP_SERVER")
SmtpMail.Send(oMsg)

Sep 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.