Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

ASP module uses GMail SMTP now encountering errors

$
0
0
I built this module to send emails to people using GMail SMTP.
It was working fine for the last couple of years.
Now, it encounters an error.... which tells me it cannot connect to the server.

Here is the code...
Code:

schema  = "http://schemas.microsoft.com/cdo/configuration/"
cdoBasic = 1
cdoSendUsingPort = 2
Dim oMsg, oConf
 
' E-mail properties

Set oMsg      = CreateObject("CDO.Message")
oMsg.From    = "sendername@gmail.com" 
oMsg.To      = "onerecipient@gmail.com;tworecipient@yahoo.com"
oMsg.CC      = "ccrecipient@hotmail.com"
oMsg.ReplyTo  = "sendername@gmail.com"
oMsg.Subject  = "Test from VBScript"
oMsg.TextBody = "If you can read this, the script worked!"
 
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver")      = "smtp.gmail.com"                  'server address
oConf.Fields(schema & "smtpserverport")  = 465                                  'port number
oConf.Fields(schema & "sendusing")        = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic                          'authentication type
oConf.Fields(schema & "smtpusessl")      =  True                                  'use SSL encryption
oConf.Fields(schema & "smtpconnectiontimeout") = 60
oConf.Fields(schema & "sendusername")    = "sendername@gmail.com"    'sender username
oConf.Fields(schema & "sendpassword")    = "senderpassword"                'sender password
oConf.Fields.Update()

Dim ServerPath, uploadsDirVar, filetoattach, resultMessage
ServerPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
uploadsDirVar = Serverpath & "test\files"
filetoattach = uploadsDirVar & "\" & "attachment.pdf"

oMsg.AddAttachment filetoattach
 
' send message
oMsg.Send()
 
' Return status message
If Err Then
    resultMessage = "ERROR " & Err.Number & ": " & Err.Description
    Err.Clear()
Else
    resultMessage = "Message sent ok"
End If
 
response.write resultMessage

The error message occurs when it encounters the "Send" command.

Has GMail changed something?

The code I am using (above) is so representative of the samples I find all over.

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>