Hi, I am updating an existing VB.NET 1.1 app to 2.0. The existing app uses the System.Web.Mail namespace to send emails and it works fine, but when I try to update to use the System.Net.Mail namespace it stops working. Has anybody any ideas why
The following is the existing code that works:
Dim msg As New System.Web.Mail.MailMessage
msg.From =
msg.To =
msg.Subject = "Subject"
msg.Body = "Body"
System.Web.Mail.SmtpMail.SmtpServer.Insert(0, "<<SMTPServerName>>")
System.Web.Mail.SmtpMail.Send(msg)
I've changed the code to the following:
Dim client As New System.Net.Mail.SmtpClient("<<SMTPServerName>>")
Dim msg As New System.Net.Mail.MailMessage(
,
, "Subject", "Body")
client.Send(msg)
Your message did not reach some or all of the intended recipients.
Subject: Subject
Sent: 13/10/2006 10:39
The following recipient(s) could not be reached:
The recipient name is not recognized
I can't understand why it worked using the Web namespace but not the Net namespace. Any advice would be gratefully accepted.
.NET Development32
|