Losing ability to send email through gmail?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Losing ability to send email through gmail?

07 Apr 2022, 01:47

Gmail is removing the ability to send emails through third-party apps (it seems like it's already been done in several countries, and will happen on May 30 in the US where I am):

https://support.google.com/accounts/answer/6010255?hl=en

I think this means that we will lose the ability to send email through gmail using the CDO COM method described by

@jack dunning here:
viewtopic.php?f=6&t=71493&hilit=send+email
@Joe Glines here:
https://www.the-automator.com/downloads/emailsender/
@JoeWinograd here:
viewtopic.php?f=76&t=67283

I think it may still work if you use an app password (as explained in Joe Glines' video), but that will require 2-factor authorization, which is a no go for my situation.

So I'm looking at alternative ways to send email through AHK. Has anyone used the CDO COM method with something other than gmail? Does the method described by Joe Winograd require an Office 365 account? Are there other ways to do this?

Thanks in advance for any help you may be able to provide.
User avatar
boiler
Posts: 17310
Joined: 21 Dec 2014, 02:44

Re: Losing ability to send email through gmail?

07 Apr 2022, 02:16

With Office 365, you can automate sending emails via the COM interface with Outlook if you have your gmail account linked to Outlook.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Losing ability to send email through gmail?

07 Apr 2022, 11:58

Thanks @boiler for the reply.

Are you talking about the Office 365 desktop programs or about Office 365 online? I'm guessing you are talking about the programs. So would that mean that Outlook 365 would nee to be installed on each computer that uses the script? Unfortunately, since the script is used by many users, this would not be possible.
User avatar
boiler
Posts: 17310
Joined: 21 Dec 2014, 02:44

Re: Losing ability to send email through gmail?

07 Apr 2022, 12:15

Yes, as far as I know, it would need to be installed.
User avatar
flyingDman
Posts: 2840
Joined: 29 Sep 2013, 19:01

Re: Losing ability to send email through gmail?

07 Apr 2022, 12:53

but that will require 2-factor authorization, which is a no go for my situation.
I have the "app password" (see here: https://support.google.com/accounts/answer/185833?hl=en) and it works just fine.
14.3 & 1.3.7
User avatar
labrint
Posts: 381
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: Losing ability to send email through gmail?

08 Apr 2022, 03:23

flyingDman wrote:
07 Apr 2022, 12:53
but that will require 2-factor authorization, which is a no go for my situation.
I have the "app password" (see here: https://support.google.com/accounts/answer/185833?hl=en) and it works just fine.
@flyingDman would you be so kind as to put in a sample code with the app password (using ComObjCreate("CDO.Message"), and how to get this app password generated via Gmail?
User avatar
labrint
Posts: 381
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: Losing ability to send email through gmail?

08 Apr 2022, 03:44

labrint wrote:
08 Apr 2022, 03:23
flyingDman wrote:
07 Apr 2022, 12:53
but that will require 2-factor authorization, which is a no go for my situation.
I have the "app password" (see here: https://support.google.com/accounts/answer/185833?hl=en) and it works just fine.
@flyingDman would you be so kind as to put in a sample code with the app password (using ComObjCreate("CDO.Message"), and how to get this app password generated via Gmail?
@JoeWinograd I have a problem using powershell to send emails from some PCs. It sends fine on some and does not work on others. I wonder if you have a solution or perhaps someone is using the CDO method with outlook accounts.
User avatar
labrint
Posts: 381
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: Losing ability to send email through gmail?

08 Apr 2022, 09:56

Nothing to worry about guys.

I set up two factor authentication by;

a) going to google account
b) logging in
c) go to security settings https://myaccount.google.com/security
d) switch on two factor authentication
e) go back to security settings
f) go to under App Passwords "Signing in to Google"
g) generate a new password for windows
h) copy the password
i) replace the password in your app with the new password generated
User avatar
flyingDman
Posts: 2840
Joined: 29 Sep 2013, 19:01

Re: Losing ability to send email through gmail?

08 Apr 2022, 11:53

@labrint I guess you got it. The app password replaces the regular password in the script. My script is not different than others you listed above (though ports and servers might be different). Just in case, here it goes:

Code: Select all

rcpnts := "john.doe@xmail.com, john@gmx.com"

fileappend,This is a test`n,attachment.txt
pmsg 							:= ComObjCreate("CDO.Message")
pmsg.From 						:= """Jane Doe"" <jane.doe@xmail.com>"
pmsg.To 						:= rcpnts
pmsg.BCC 						:= ""   												; Blind Carbon Copy, Invisible for all, same syntax as CC
pmsg.CC 						:= ""													; Somebody@somewhere.com, Other-somebody@somewhere.com
pmsg.Subject 					:= "See attached"
;pmsg.TextBody 					:= "I thought you might be interested in attached document"
pmsg.HtmlBody 					:= "<html><body><table border='1'><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr><tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table> </body></html>"
sAttach   						:= a_scriptdir "\attachment.txt" 						; can add multiple attachments, the delimiter is |
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 			:= "Jane.doe@xmail.com"
fields.sendpassword 			:= "abcd efgh klmn qwer"								; app password
fields.smtpconnectiontimeout	:= 60
schema 							:= "http://schemas.microsoft.com/cdo/configuration/"
pfld 							:= pmsg.Configuration.Fields
For field,value in fields
	pfld.Item(schema . field) 	:= value
pfld.Update()
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
	pmsg.AddAttachment(A_LoopField)
pmsg.Send()
filedelete,attachment.txt
return
14.3 & 1.3.7
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: Losing ability to send email through gmail?

10 Apr 2022, 11:58

Today I use BLAT.exe - has worked perfectly for many years. But is a bit tricky to install and handle (and the future is a bit uncertain).

I have tested Thunderbird (Command line arguments)
an example .: thunderbird.exe -compose "to='email@domain.com',subject='Some Subject',preselectid='id1',body='Message Body',attachment='File.txt'" ( from Thunderbird compose email in a batch script )
I failed to automatically send an email (through Thunderbird)
Is it possibly?
User avatar
JoeWinograd
Posts: 2213
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Losing ability to send email through gmail?

10 Apr 2022, 14:02

labrint wrote:It sends fine on some and does not work on others
I'm not a PowerShell expert...I have only two thoughts on this re the computers where it does not work:

(1) The PATH variable may not have the location of the PowerShell executable in it, in which case you could either add it to the PATH or use the full path to it in your code.

(2) The PowerShell execution policy may be preventing the PowerShell code from running. PowerShell has four execution policies:

Restricted: No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned: Only scripts signed by a trusted publisher can be run.
RemoteSigned: Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted: No restrictions - all scripts can be run.

If this is the issue, either change the execution policy on the system to one that allows the code to run or put the execution policy (or a bypass) in your code. Regards, Joe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Marium0505, Rohwedder and 143 guests