2010-02-23

Send Email By SMTP

Imports System.Net.Mail


Public
Sub SendEmail()

Dim client As New SmtpClient()
Dim sendTo As New MailAddress("sendToAccount@gmail.com")
Dim from As MailAddress = New MailAddress("from@address.com")
Dim
message As New MailMessage(from,sendTo)


message.IsBodyHtml = True
message.Subject = "Test SMTP"
message.Body = "Got it!!"

' Use the same account in app.config to authenticate.
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("yourAccount@xxx.com", "YourPassword")


client.Host = "smtp.xxx.com"
client.UseDefaultCredentials = False

client.Credentials = basicAuthenticationInfo

'' For smtp config
'' google use EnableSsl=True and Port = 587

client.EnableSsl = False
client.Port = 25

Try

client.Send(message)
Console.WriteLine("SUCCESS")

Catch ex As Exception

Console.WriteLine("SEND FAIL")

End Try

End Sub

14 ความคิดเห็น:

Anonymous said...

I will add this blog to my favorites, it is great.
watch harry potter and deathly hallows online

Anonymous said...

Wow all I can say is that you are a great writer! Where can I contact you if I want to hire you?

Anonymous said...

hi, new to the site, thanks.

john said...

Nice post!
thank for your sharing!

Anonymous said...

Hi - I am really delighted to find this. Good job!

Luiz el Ginan said...

thank you very helpful , visit myBlog : http://semicoFramework.blogspot.com

Ecommerce web development said...

I hope this is very useful visual basic code to send an email by SMTP.. I will make use of it when it is necessary. Thanks for sharing the code and article.

.netobfuscator said...

This visual basic code help me a lot to send emails. I hope it will help other people also.
.net obfuscators

Anonymous said...

Hey - I am definitely delighted to find this. cool job!

Anonymous said...

Hi - I am certainly delighted to find this. cool job!

Anonymous said...

I'm so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this greatest doc. low cost car insurance

Anonymous said...

Hey - I am definitely glad to find this. Good job!

informasi lowongan kerja said...

nice tutor, i will back visit you :)

Free Directory said...

This helps me so much