Problems with System.Net.Mail

P

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("(e-mail address removed)")
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 = "(e-mail address removed)"
oMsg.Subject = "whatever"
oMsg.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = AppSettings("SMTP_SERVER")
SmtpMail.Send(oMsg)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top