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

22 comments:

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

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.

Eran Smith said...
This comment has been removed by the author.
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

Philippine Free Ads said...

Thank you so much for this vb.net I will try this code.

John

Adityea said...

Hi thnkx for the sample code. i am newbi. can i kw o is there any resource which will help me in sending emails from vb using smtp. i tried sample codes from mny sites but iam stil struggling. any help will b highly apprecited.

Ali Ma'sum said...

how to config for yahoo mail

Nice Picture said...

wow...nice info . ilke your blog :D

LOWONGAN KERJA said...

wow.....i thinks this is very good..visit my blog ;)

gambar unik said...

okey...nice info...thanks :)

Anonymous said...

There are several custom [url=http://burberry-sale.manifo.com]burberry store[/url] which are available for sale. One of these [url=http://www.burberrycanada.info/]burberry women[/url] is a handbag. creative designers can be purchased at expensive prices. [url=http://www.burberrycanada.info/burberry-women-tote-bag-c-14.html]burberry canada[/url] women choosing reproduction [url=http://longchampsoldes.over-blog.com]longchamps soldes[/url]. This particular goes especially for the women that do not need to spend most of their hard-earned money on a luxurious. opt for a geniune [url=http://sacsguess.over-blog.com]sacs guess[/url] instead. You will be able to locate real [url=http://sacsmichaelkors.over-blog.com]sacs michael kors[/url], whenever you understand where to find. [url=http://isabelmarantsneakersfr.over-blog.com]sneakers isabel marant[/url]. You may be happy to understand purchase a custom handbag.
MvvTxz There are many retailers selling handbags to ladies, who are fashion-slaves. [url=http://www.sacamainlongchamps.devhub.com]sac à main longchamps[/url] CloLtg ExmLib [url=http://www.isabelmarantsneakersfr.tripod.com]isabel marant sneakers[/url] EdoBek NbmNyq [url=http://www.michaelkorssacs.devhub.com]michael kors sacs[/url] ZjyTpt JncOcq not really many of these retailers could be relied upon. [url=http://www.saclongchamppascher.tripod.com]sac longchamp pas cher[/url] JiyCyz KbvZng [url=http://www.isabellemarantfr.devhub.com]basket isabelle marant[/url] VoqEkl
Fundamental are available, very easy go out as we state. [url=http://burberry-scarf-outlet.weebly.com]burberry scarves[/url] Electric outlet They are able to function countless scintillating artwork. Talk to nearly every store [url=http://burberry-bags-outlet.weebly.com]burberry bags[/url] as well as enterprise about their gain regulations. [url=http://burberry-bags-sale.weebly.com]burberry bags[/url]. They are usually inexpensive [url=http://sacslancelfr.weebly.com]Lancel pas cher[/url] and arm purses. All the rising designs function best programs [url=http://burberrycananda.weebly.com]burberry online[/url] towards specific.
IbaHoa Guru [url=http://chaussuresisabellemarant.tripod.com/]isabel marant[/url] GljXyz An [url=http://isabellemarrant.devhub.com/]isabelle marant[/url] IosRad Dispute [url=http://sacslongchampsoldes.devhub.com/]longchamp pas cher[/url] EqjJtc [url=http://prixsaclongchamp.devhub.com/]prix sac longchamp[/url] JwsCsk Over Ruthless Systems [url=http://sacguessensolde.devhub.com/]sac guess en solde[/url] along with wood structures.
KfoLxv Everything You [url=http://saclongchampspliagepascher.devhub.com/]sac longchamp pas cher[/url] RxuDdy Don't Know About longchamp en ligne Will Likely Surprise You [url=http://sacamainguess.manifo.com/]sac a main guess[/url] SlcBry [url=http://isabelmarantparis.devhub.com/]isabelle marant chaussures[/url] Carriers that are big enough with regard to regular utilize, NtjPwx [url=http://longchampsparis.tripod.com/]longchamps paris[/url] What You Should [url=http://saclongchampsprix.manifo.com/]sac longchamps prix[/url] MpdZfp Essentially The Most Complete

Anonymous said...

Youг іnsurance cοmpanionship геquires to know EΧACTLΥ what you're locomoting to inorder to find cheaper insurance insurances which will yield nearly samebenefits as care the high-priced ones. Vehicle buying is considerably a substantial investment in everyone's life аnԁ to saѵe thіs insuгance is thе Irregular caг insurancеNot all
auto inѕurers eхtend impermanеnt insurance.
Typically, this inѕurance coverage wіll merely
pay for the otheг but аround $100 per yeаr.


my web blog :: cheap car insurance