This is the error when i tried to test the following codes below:

ERROR --> Must issue a STARTTLS command first. 15sm458594bwz.12 (530).

Dim message As New MailMessage

    message.From = New MailAddressCollection("from@gmail.com")
    message.To = New MailAddressCollection("to@gmail.com")
    message.Subject = "This is a simple message"
    message.BodyText = "Hello, Joe!"
    message.BodyHtml = "Hello, <b>Joe</b>!"


Dim smtp As New Smtp

    smtp.Connect("smtp.gmail.com", 587)
    smtp.Send(message) <-- The error occurs when it reads this line of code**
    smtp.Disconnect()
    smtp.Dispose()

asked 12 Mar '10, 02:31

Aaron1's gravatar image

Aaron1
161
accept rate: 0%

edited 17 Mar '10, 14:49

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.2k18


To enable the SMTP/SSL calling a different variant of a Connect method is needed.

smtp.Connect("smtp.gmail.com",587, Nothing, SmtpSecurity.Explicit)

Gmail also requires you to provide a valid username and password when sending email. The whole code for sending the email via smtp.gmail.com follows:

    Dim message As New MailMessage

    message.From = New MailAddressCollection("from@gmail.com")
    message.To = New MailAddressCollection("to@gmail.com")
    message.Subject = "This is a simple message"
    message.BodyText = "Hello, Joe!"
    message.BodyHtml = "Hello, <b>Joe</b>!"


    Dim smtp As New Smtp

    ''# connect using explicit SSL
    smtp.Connect("smtp.gmail.com", 587, Nothing, SmtpSecurity.Explicit)

    ''# authenticate
    smtp.Login("myaccount@googlemail.com", "mypassword")

    ''# send the message
    smtp.Send(message) 

    ''# cleanup
    smtp.Disconnect()
    smtp.Dispose()

Note that you have to reference the Rebex Secure Mail component when using the SMTP/SSL.

link

answered 12 Mar '10, 12:49

Martin%20Vobr's gravatar image

Martin Vobr ♦♦
335310
accept rate: 37%

edited 01 Apr '10, 09:52

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
78217

or how to enable SSL?

link
This answer is marked "community wiki".

answered 12 Mar '10, 02:57

Aaron1's gravatar image

Aaron1
161
accept rate: 0%

Thanks Martin!

Tried your suggestion and it works by using Rebex Secure Mail component!

Thank you very much.

link

answered 15 Mar '10, 05:48

Aaron2's gravatar image

Aaron2
16
accept rate: 0%

Great. It's nice to know that you've got it working. If the answer works could you please mark my answers as the correct one by clicking on the check box icon left to the proposed answer? This would help future visitors find the working solution.

(15 Mar '10, 09:23) Martin Vobr ♦♦

Thanks Martin! I will try your other suggestion

link

answered 29 Mar '10, 06:20

aaron's gravatar image

aaron
16
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×22
×19
×17
×14
×1

Asked: 12 Mar '10, 02:31

Seen: 2,206 times

Last updated: 01 Apr '10, 09:52