Link to home
Start Free TrialLog in
Avatar of cmdolcet
cmdolcetFlag for United States of America

asked on

Email Automation in VB 2017

I am trying to automate an email inside my vb.net program. I am using the following line of code below.
I get to the SMTP.Send(Mail) and get an error. (See attached image). It will never show up in my mailbox.


  Dim Mail As New Net.Mail.MailMessage
        Mail.Subject = "Notification Email."
        Mail.To.Add("********@gmail.com")
        Mail.From = New MailAddress("*******@*******corporation.com")
        Mail.Body = "This is a notice that a report was created."

        Dim SMTP As New SmtpClient("smtp.gmail.com")
        SMTP.EnableSsl = True
        SMTP.Credentials = New System.Net.NetworkCredential("******@gmail.com ", "******")
        SMTP.Port = "587"
        SMTP.Send(Mail)

Open in new window

Email-Error.PNG
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cmdolcet

ASKER

shaun,

I believe that this is the credentials from the incoming connection so in my case gmail.

I want to send email through my office 365 account to my gmail account just for testing purposes.

I tried your suggestion and got the same result.
Shaun,

Actually you are correct in your above statement. You just need to match up the SMTP client

Thanks!