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

Update VB6 to VB.NET 2.0 Email Send

P: n/a
Hi,
I have following codes in VB6 for sending the email on a server installed
SMTP. It works fine. Now I want to update it with VB.NET 2.0 by using
..NET.Mail object.
VB6 code:
Dim myMail
Set myMail=CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "Testing"
myMail.To = "so*****@yahoo.com"
myMail.TextBody = "This is a message."
myMail.Send
Set myMail = Nothing

VB.NET codes:
Dim myMail As New MailMessage
myMail.From = New MailAddress("Testing")
myMail.To.Add("so*****@yahoo.com")
myMail.Subject = "Sending email with Net.Mail"
myMail.Body = "This is a message."
Dim client As New SmtpClient()
client.Host = [myservername]
client.Send(myMail)

I had an error when fetched .From property which is omited in VB6, I want to
know what I have to put there? If I run it from server, do I need to set host
property?
How to make it work properly?
Thanks in advance
Oct 31 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I find the solution by myself.
From must be a valid email address
Host is server DSN name
and more important is the following line
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

"Li Pang" wrote:
Hi,
I have following codes in VB6 for sending the email on a server installed
SMTP. It works fine. Now I want to update it with VB.NET 2.0 by using
.NET.Mail object.
VB6 code:
Dim myMail
Set myMail=CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "Testing"
myMail.To = "so*****@yahoo.com"
myMail.TextBody = "This is a message."
myMail.Send
Set myMail = Nothing

VB.NET codes:
Dim myMail As New MailMessage
myMail.From = New MailAddress("Testing")
myMail.To.Add("so*****@yahoo.com")
myMail.Subject = "Sending email with Net.Mail"
myMail.Body = "This is a message."
Dim client As New SmtpClient()
client.Host = [myservername]
client.Send(myMail)

I had an error when fetched .From property which is omited in VB6, I want to
know what I have to put there? If I run it from server, do I need to set host
property?
How to make it work properly?
Thanks in advance

Oct 31 '06 #2

P: n/a
Yes, you need to specify Host because you could use any SMTP server so the
control needs to know specifically which one you want to use.

Same for From.

Rick

I had an error when fetched .From property which is omited in VB6, I want
to
know what I have to put there? If I run it from server, do I need to set
host
property?
How to make it work properly?
Thanks in advance


Oct 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.