Sending Email in VB 2005

R

Rico

Hello,

I have an application in VB 2003 that uses System.Web that creates and sends
an email. I'm trying to turn this application into a Windows Service in VB
2005 and have discovered that System.Web.Mail is replaced by
System.Net.Mail, but it seems the "To" property is read only now? How do I
set this property so I can actually send the email?

Any direction would be greatly appreciated.

Thanks!
Rick
 
T

tclancey

Try

'// Setup the new message.

Dim Message As New MailMessage("To", "From", "Subject", "Message")

'// Set the server to receive the smtp, exchange server or remote smtp
server

Dim EmailClient As New SmtpClient("DNS or IP")

'// If authentication is require it's set here.

' Dim SMTPUserInfo As New System.Net.NetworkCredential("Username",
"Password")

'// Defined by the above process, but doesn't seem to make much difference
is authentication is not required.

EmailClient.UseDefaultCredentials = False

'// If UserInfo is required this also need to be un-remmed

' EmailClient.Credentials = SMTPUserInfo

'// Send the Email!

EmailClient.Send(Message)

'// And confirm!

MsgBox("Done!")
 
R

Rico

Hi tc,

Sorry for the delay in responding, I've been away for a while.

Thanks. I will give that a try.

Rick
 
R

Rico

Sweet! It works! Thanks TC!

tclancey said:
Try

'// Setup the new message.

Dim Message As New MailMessage("To", "From", "Subject", "Message")

'// Set the server to receive the smtp, exchange server or remote smtp
server

Dim EmailClient As New SmtpClient("DNS or IP")

'// If authentication is require it's set here.

' Dim SMTPUserInfo As New System.Net.NetworkCredential("Username",
"Password")

'// Defined by the above process, but doesn't seem to make much difference
is authentication is not required.

EmailClient.UseDefaultCredentials = False

'// If UserInfo is required this also need to be un-remmed

' EmailClient.Credentials = SMTPUserInfo

'// Send the Email!

EmailClient.Send(Message)

'// And confirm!

MsgBox("Done!")
 

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

Top