When running the following script I get the errors -2147220975 and Transport code error: 0x80040217
on error resume next
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "tom.watt.vulpes@gmail.com"
oMsg.To = "tom.watt.vulpes@gmail.com"
oMsg.Subject = "Test from VBScript"
oMsg.TextBody = "If you can read this, the script worked!"
objMsg.AddAttachment "C:\BLA_BLA.txt"
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport") = 465
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl") = True
oConf.Fields(schema & "sendusername") = "tom.watt.vulpes@gmail.com"
oConf.Fields(schema & "sendpassword") = "PASSWORD"
oConf.Fields.Update()
oMsg.Send()
If Err Then
resultMessage = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
resultMessage = "Message sent ok"
End If
Wscript.echo(resultMessage)
I've tried countless scripts from the internet but none of them seem to work. What am I doing wrong? Thanks, Tom
EDIT: I am running Windows 10
Transport code error: 0x80040217 can be a few different things depending on the situation. The links below should guide you in the right direction...
Something that I have found that may help in relation to this was that the domain I was wanting to use this script for had a SPF record with a hard fail attached to it and so then only their specific email server would work with this which in my case was Office 365 but when testing I was using their ISP and attempting to relay unauthenticated through them.
So check SPF also, hope this helps.
Cozzie
User contributions licensed under CC BY-SA 3.0