Send Email Directly from AutoHotkey

Post your working scripts, libraries and tools for AHK v1.1 and older
daywalker
Posts: 32
Joined: 18 Jun 2019, 01:37

Re: Send Email Directly from AutoHotkey

Post by daywalker » 13 Jan 2021, 07:36

Nice script. How to realise NOREPLY emails?

User avatar
zvit
Posts: 224
Joined: 07 Nov 2017, 06:15

Re: Send Email Directly from AutoHotkey

Post by zvit » 17 Jan 2021, 01:45

Works great but I have a question. I have nice email templates that were created via HTML. (I use CloudHD email templates plugin) Is there a way to have the email sent in an HTML format? Meaning, that in ahk I would either paste the HTML or have ahk read the HTML from the HTML template file?

DRocks
Posts: 565
Joined: 08 May 2018, 10:20

Re: Send Email Directly from AutoHotkey

Post by DRocks » 24 Feb 2021, 07:19

Very nice thanks a lot! I've been wondering about that for a while.

Here's a snippet how I made a working attachment test:

Code: Select all

; Attachment feature separated by |
facture := A_ScriptDir . "\Facture-18.pdf"
doc1 := A_ScriptDir . "\doc1.pdf"
doc2 := A_ScriptDir . "\doc2.pdf"

sAttach := facture "|" doc1 "|" doc2 ; can add multiple attachments (the delimiter is "|" )

bdrumm
Posts: 1
Joined: 15 Oct 2015, 21:14

Re: Send Email Directly from AutoHotkey

Post by bdrumm » 04 Aug 2021, 12:37

image.png
(10.57 KiB) Downloaded 100 times
the URL:

Code: Select all

http://schemas.microsoft.com/cdo/configuration/
is down.

This script wont work without that URL.

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Send Email Directly from AutoHotkey

Post by JoeWinograd » 04 Aug 2021, 14:00

bdrumm wrote:This script wont work without that URL.
I'm hoping for "temporarily unavailable", as a removal or a name change would break a gazillion programs/scripts. Give it a while and try again later.

Btw, here's a thread that I posted about CDO, but it has a PowerShell solution that does not rely on http://schemas.microsoft.com/cdo/configuration/, so you may want to give that a try:

https://www.autohotkey.com/boards/viewtopic.php?f=76&t=67283

Regards, Joe

Albireo
Posts: 1747
Joined: 16 Oct 2013, 13:53

Re: Send Email Directly from AutoHotkey

Post by Albireo » 10 Apr 2022, 12:01

Is this really a possible way to solve this on?

tantomed
Posts: 2
Joined: 13 May 2022, 21:51

Re: Send Email Directly from AutoHotkey

Post by tantomed » 15 May 2022, 16:39

New user here. Got the Gmail to work...also had to manually select "allow less secure apps," but did anyone else see that Gmail has a notification above this option now that says "As of May 31, 2022 we will no longer allow less secure apps" or something like that? Anyone have a good backup? I tried multiple other email clients, and perhaps just dont have the script/ports/etc right, but I basically tried both the original posters code (that works with Gmail), plus I have tried the reposters variants where TLS should work (vs SSL), but so far cant get Outlook, AOL, Yahoo, or Yandex to work, despite making sure I am using the correct SMTP address and the correct port. Port 25 is blocked for me on ATT Fiber. Any thoughts?

1apsalman1
Posts: 6
Joined: 12 Apr 2022, 12:57

Re: Send Email Directly from AutoHotkey

Post by 1apsalman1 » 15 May 2022, 23:45

hi, i'm noob. I tried the source, but an error occurred and I don't know how to solve it, so I leave a question.
The message could not be sent to the SMTP server. The transmission error code is 0x80040217 . The server response is not available .
---> 034: pmsg.Send()

Albireo
Posts: 1747
Joined: 16 Oct 2013, 13:53

Re: Send Email Directly from AutoHotkey

Post by Albireo » 16 May 2022, 06:48

What is not working?
Or more importantly what is it you want to do?
(some code?)

tantomed
Posts: 2
Joined: 13 May 2022, 21:51

Re: Send Email Directly from AutoHotkey

Post by tantomed » 18 May 2022, 22:19

Albireo wrote:
16 May 2022, 06:48
What is not working?
Or more importantly what is it you want to do?
(some code?)

When I use gmail with the provided code, it works well (sending an email when the "if" occurs). So this first one is working...but at the end of this month I dont think it will anymore given the notice I saw in Gmail about no longer allowing "less secure apps."

Code: Select all

fields := Object()
fields.smtpserver := "smtp.gmail.com" ; specify your SMTP server
fields.smtpserverport := 465 ; 25
fields.smtpusessl := True ; False
fields.sendusing := 2 ; cdoSendUsingPort
fields.smtpauthenticate := 1 ; cdoBasic
fields.sendusername := "[email protected]"
fields.sendpassword := "Password"
fields.smtpconnectiontimeout := 60
schema := "http://schemas.microsoft.com/cdo/configuration/"  ; Do not change
So in order to find an alternative, I tried Outlook, Aol, Yahoo, Yandex. I made sure to use the proper smtp server/port info I found on their websites/online. None worked using the original Gmail code above (likely because require TLS), but even when I tried to add in TLS (with multiple different port options), it didnt work (see below for just two examples). Basically tried added fields.sendtls instead of fields.smtpusessl, or tried both, then tried multiple port options with this.

Code: Select all

fields := Object()
fields.smtpserver := "smtp-mail.outlook.com" ; specify your SMTP server
fields.smtpserverport := 587
fields.sendtls := True
fields.sendusing := 2 ; cdoSendUsingPort
fields.smtpauthenticate := 1 ; cdoBasic
fields.sendusername := "[email protected]"
fields.sendpassword := "Password"
fields.smtpconnectiontimeout := 60
schema := "http://schemas.microsoft.com/cdo/configuration/"  ; Do not change


fields := Object()
fields.smtpserver := "smtp-mail.outlook.com" ; specify your SMTP server
fields.smtpserverport := 465 ; 25
fields.sendtls := True
fields.smtpusessl := True ; False
fields.sendusing := 2 ; cdoSendUsingPort
fields.smtpauthenticate := 1 ; cdoBasic
fields.sendusername := "[email protected]"
fields.sendpassword := "Password"
fields.smtpconnectiontimeout := 60
schema := "http://schemas.microsoft.com/cdo/configuration/"  ; Do not change
Last edited by BoBo on 13 Jun 2022, 23:15, edited 1 time in total.
Reason: Added [code][/code]-tags.

corcova
Posts: 14
Joined: 23 Apr 2022, 11:59

Re: Send Email Directly from AutoHotkey

Post by corcova » 13 Jun 2022, 23:05

@tantomed
im having the same issue. gmail stop working. tried many other smpt mails and none has workd. did you find some alternative?

Albireo
Posts: 1747
Joined: 16 Oct 2013, 13:53

Re: Send Email Directly from AutoHotkey

Post by Albireo » 14 Jun 2022, 01:52

I have not tried using Thunderbird with AHK (but it should work)

lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Send Email Directly from AutoHotkey

Post by lblb » 14 Jun 2022, 04:14

Gmail should still work (it does for me) when you use an App password:

viewtopic.php?f=76&t=102434&p=455402#p455548

corcova
Posts: 14
Joined: 23 Apr 2022, 11:59

Re: Send Email Directly from AutoHotkey

Post by corcova » 14 Jun 2022, 12:21

thank you, just created a app password and it is working again. uhuuuuu
lblb wrote:
14 Jun 2022, 04:14
Gmail should still work (it does for me) when you use an App password:

viewtopic.php?f=76&t=102434&p=455402#p455548

Post Reply

Return to “Scripts and Functions (v1)”