-
May 7th, 2022, 09:45 AM
#1
Thread Starter
Member
Gmail
I have this code, but keep getting "Failure Sending Email" message
server is smtp.gmail.com
Username is email address
Code works for 1and1 email addresses its just gmail it seems
Code:
Sub SendTheMail()
rp1.Emailer2(txtto.Text, txtFrom.Text, txtSubject.Text, txtMessage.Text, txtFrom.Text, "smtp.gmail.com", "*******", 465)
End Sub
Sub Emailer2(ByVal to_who As String, ByVal from_who As String, ByVal txtsubject As String, ByVal txtbody As String, ByVal UserName As String, ByVal smtpServerName As String, ByVal PasswordForEmailServer As String, ByVal aport As Integer)
Dim SmtpServer As New SmtpClient(smtpServerName, aport)
SmtpServer.EnableSsl = True
SmtpServer.Credentials = New Net.NetworkCredential(UserName, PasswordForEmailServer)
Dim mail As New MailMessage(from_who, to_who, txtsubject, txtbody)
Try
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Help is appreciated
-
May 9th, 2022, 04:49 AM
#2
Re: Gmail
If you are sure all settings are correct than go to your Google account, Less secure app access and turn it on. If this works it's a fix that will only be available to the end of this month, after that Google is not allowing Less secure app access and moving to two factor authentication.
-
May 9th, 2022, 10:29 AM
#3
Thread Starter
Member
Re: Gmail
Hi Karen, thanks for this, it seems moving forward VB access is no longer possible then? But thanks for the reply
-
May 9th, 2022, 11:57 AM
#4
Re: Gmail
it seems moving forward VB access is no longer possible then?
It's not a VB or even C# issue, it's Google's security changes.
-
May 10th, 2022, 09:52 AM
#5
Re: Gmail
From what I recall you also need a port to send gmail.
Google and says: If you're using SSL, enter 465. If you're using TLS, enter 587.
Edit. OK I saw you have a port waaay right in the code. It won't hurt to try 587.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
May 10th, 2022, 04:56 PM
#6
Re: Gmail
Moderator Actions: Moved to General Developer Forum
-
May 10th, 2022, 06:37 PM
#7
Lively Member
Re: Gmail
That is a nice generic code example.🤔
-
May 11th, 2022, 12:44 AM
#8
Addicted Member
Re: Gmail
G'Day OP
Originally Posted by raphipps
I have this code, but keep getting "Failure Sending Email" message
It would be much faster to fix this 'issue' which I'm certain is all about security by cutting your own SMTP server in VB6
Search this forum and there is more than 1 .zip that contains time tested code base
-
May 11th, 2022, 11:29 AM
#9
Lively Member
Re: Gmail
Originally Posted by kareninstructor
If you are sure all settings are correct than go to your Google account, Less secure app access and turn it on. If this works it's a fix that will only be available to the end of this month, after that Google is not allowing Less secure app access and moving to two factor authentication.
Pity rolling out an app in net4+ is probably even easier. One to make custom emails etc.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|