Results 1 to 9 of 9

Thread: Gmail

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Location
    UK
    Posts
    61

    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

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,671

    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Location
    UK
    Posts
    61

    Re: Gmail

    Hi Karen, thanks for this, it seems moving forward VB access is no longer possible then? But thanks for the reply

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,671

    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.

  5. #5
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,171

    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.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,965

    Re: Gmail

    Moderator Actions: Moved to General Developer Forum
    "Code is like humor. When you have to explain it, itís bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  7. #7
    Member
    Join Date
    Apr 2022
    Posts
    62

    Re: Gmail

    That is a nice generic code example.🤔

  8. #8
    Addicted Member jg.sa's Avatar
    Join Date
    Nov 2017
    Location
    South Australia ( SA )
    Posts
    164

    Re: Gmail

    G'Day OP

    Quote Originally Posted by raphipps View Post
    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

  9. #9
    Member
    Join Date
    Apr 2022
    Posts
    62

    Re: Gmail

    Quote Originally Posted by kareninstructor View Post
    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
  •  



Click Here to Expand Forum to Full Width