send email from a gmail account ... vb.net

Does anybody have code that works to send email in vb.net code using an exsisting google email account?

troyvwAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jakethecatukCommented:
google is a better friend than EE you know.

http://vbnetsample.blogspot.com/2007/06/send-email-with-gmail.html
0
edster9999Commented:
Or... an even simpler way is to send the mail out through your existing setup.
Just as if you were specifing you@yourcompany.com
Gmail has no SPF records (a record that blocks where email comes from) so if you just set the outbound email to you@gmail.com it will look like it came from gmail.
0
troyvwAuthor Commented:
jakethecatuk: I tried your code and got a message that I cannot connect to the remote server.  I tried other code with the same result...
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Coralie CrumrineCommented:
Try something like this:
'//GMail Stuff
    Public Sub GmailTest()
        Dim MyMailMessage As New MailMessage
        MyMailMessage.From = New MailAddress("xxxxx@gmail.com")
        MyMailMessage.To.Add("xxxxx@xxxxx.net")
        MyMailMessage.Body = "This is a test text sent " & Now

        'Dim SMTPServer As New SmtpClient("smtp.gmail.com")
        Dim SMTPServer As New SmtpClient
        SMTPServer.Host = "smtp.gmail.com"
        SMTPServer.Port = 587
        SMTPServer.Credentials = New Net.NetworkCredential("gMailUserName", "gMailPassword")
        SMTPServer.EnableSsl = True

        SMTPServer.Send(MyMailMessage)
        Inform("message sent")
    End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jakethecatukCommented:
is port 587 allowed outbound from your PC?

I'm no developer so I can't help much further besides pointing you at a piece of code that is supposed to do what you want.

This is taken from the GMAIL website: -
'...Please note that if your client does not support SMTP authentication, you won't be able to send mail through your client using your Gmail address.

Also, if you're having trouble sending mail but you've confirmed that encyrption is active for SMTP in your mail client, try to configure your SMTP server on a different port: 465 or 587.
...'
0
13598Commented:
try this:
Imports System.Net.Mail
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sEmailAddress As String
        Using email As New System.Net.Mail.MailMessage
            Dim eclient As New System.Net.Mail.SmtpClient
                       Dim basicAuthenticationInfo As New System.Net.NetworkCredential("yourgmailusername", "yourpassword")
            'Put your own, or your ISPs, mail server name onthis next line
            eclient.Host = "smtp.gmail.com"
            sEmailAddress = "youremail@gmail.com"
            email.From = New MailAddress(sEmailAddress)
            eclient.EnableSsl = True
            email.To.Add(New MailAddress("blah@yahoo.com"))
           
            email.Subject = "gmail code"
            email.Priority = MailPriority.Normal
            email.IsBodyHtml = True
            email.Attachments.Add(New Attachment("c:\gmail.txt"))
            email.Body = "How are you doing? "
            eclient.UseDefaultCredentials = False
            eclient.Credentials = basicAuthenticationInfo

            eclient.Send(email)
        End Using ' Using email As New System.Net.Mail.MailMessage
    End Sub
End Class
0
troyvwAuthor Commented:
This code worked for me
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.