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.