Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2008, 08:22 PM
Authorized User
 
Join Date: Jun 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to send mail with vb.net

Hi, Hopefuly somebody can help me. I'm trying to send mail by vb.net for a while now, but somehow the examples on the web don't seem to work.

This is what I did last to send mail by the smtp server of my gmail account. I wonder what it is that I'm doing wrong here.

thanx in advance, Koen


        Dim From As MailAddress = New MailAddress("[email protected]")
        Dim [To] As MailAddress = New MailAddress("[email protected]")
        Dim Message As MailMessage = New MailMessage(From, [To])
        Message.Subject = "Using the SmtpClient class."
        Message.Body = "Using this feature, you can send an e-mail message from an application very easily."

        client = New SmtpClient("smtp.gmail.com")

        client.EnableSsl = False
        client.Credentials = New System.Net.NetworkCredential("myusername", "mypassword")

        MsgBox("Sending an e-mail message to " & [To].Address & " by using SMTP host " & client.Host & " port " & client.Port)

        client.Send(Message)
 
Old July 19th, 2008, 09:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

do you receive any error?? the code looks goods at first sight... do you receive anything from send???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old July 19th, 2008, 09:58 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

AFAIK, Google's mail server requires SSL:

http://www.google.com/search?hl=en&q...mail.com%22%29

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old July 19th, 2008, 04:37 PM
Authorized User
 
Join Date: Jun 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah, thanx a lot! I thought that gmail SSL should be off. Turning it on wasn't enough though, I also had to fill in client.Port = 587. Now it works!
greetz koen

 
Old July 20th, 2008, 05:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome. Glad it's working.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
Send calendar invite using System.Net.Mail bbeau .NET Framework 2.0 0 November 20th, 2007 09:28 PM
How to send the mail in ASP.NET n.nsivakumar ASP.NET 1.0 and 1.1 Professional 2 July 26th, 2006 03:49 PM
send MASS Emails in ASP.NET 2 with VB.NET 2005 alexdcosta ASP.NET 2.0 Basics 1 July 17th, 2006 12:31 AM
Send mail failed using asp.net anujrathi ASP.NET 1.0 and 1.1 Professional 1 June 22nd, 2006 07:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.