Hi jNizM,
Thanks for jumping in...much appreciated!
> As far as I remember, CDO does not (official) support TLS over 587.
After a week at this, I'm now pretty convinced that that's the case.
> undocumented setting for TLS over 587. can you try it?
fields.sendtls:= True
I found that before posting here, but as far as I can tell, the
fields.smtpusetls field does not seem to exist. I can't find it (or the named constant cdoSMTPUseTLS) documented in the CDO Namespace, and using it in the AutoHotkey script (set to True or 1) doesn't work.
Edit: I re-read this post after submitting it and noticed that your idea is
fields.sendtls, whereas the one I found is
fields.smtpusetls. I'll test yours as soon as I can, but the problem right now is that I can't do anything on O365 because Microsoft has blocked my account...got an email that says: "We noticed some unusual activity in your Outlook.com account. To help protect you, we've temporarily blocked your account." Too much email sending while testing, I guess...and I haven't been able to unblock it yet. End Edit.
I also found a post with
pmsg.SendTLS() in it...did not work.
I even tried port 25, as there are many posts of success with it a few years ago with
smtp.office365.com, but it failed for me. My first guess was that Microsoft shut it down since so many ISPs now block 25 (most email sending has transitioned from 25 to 465 and 587), but a member at another user forum says that 25 works for him now, so I suppose that it is
my ISP blocking it. In any event, port 25 is not a viable long term solution.
Another thought was that Office 365 switched to NTLM authentication. I played with that for an hour...no joy.
Then that same member at another user forum that I mentioned above said that he stopped using CDO and moved to PowerShell's
Send-MailMessage because CDO was removed from Exchange systems. As I know virtually nothing about PowerShell, he wrote some PowerShell code for me that I was able to incorporate into my AutoHotkey script. For anyone interested, here's a working AutoHotkey script with that member's PowerShell code in it:
Code: Select all
PSexe:="powershell.exe"
EmailSubject:="PowerShell Send-MailMessage in AutoHotkey script"
EmailBody:="The time is: " . A_Now
; Office365
EmailFrom:="[email protected]"
EmailTo:="[email protected]"
EmailPassword:="YourOutlookPassword"
SMTPserver:="smtp.office365.com"
SMTPport:="587"
; Gmail
EmailFrom:="[email protected]"
EmailTo:="[email protected]"
EmailPassword:="YourGmailPassword"
SMTPserver:="smtp.gmail.com"
SMTPport:="587"
PScmd:="""" . "Send-MailMessage -From '" . EmailFrom . "' -to '" . EmailTo . "' -Subject '" . EmailSubject . "' -Body '" . EmailBody
. "' -SmtpServer '" . SMTPserver . "' -port '" . SMTPport . "' -UseSsl -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('"
. EmailFrom . "', (ConvertTo-SecureString -String '" . EmailPassword . "' -AsPlainText -Force)))" . """"
Run,%PSexe% -command %PScmd%,,Hide
ExitApp
It works with both O365 and Gmail SMTP on port 587.
I've stopped trying to get the CDO code to work, but will certainly be happy to test any other ideas for it. Thanks, Joe