I've tried about a dozen scripts I found in various forums but I can't get any to work.
I need one specifically for Gmail but it can be any script that allows you to set the SMTP server, port, sender, receiver, subject/content and include an attachment file.
If you have one handy please enlighten me with your gift!
Thanks.
Sending email with AHK Topic is solved
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
Hi
try
I hopé it help
try
Code: Select all
ComObjError(false) ;disable COM error messages for some non available properties
m := ComObjCreate("Outlook.Application").CreateItem(0)
m.Subject := "Pick List" A_Tab ORDEN A_Tab CONSECU
m.To := "[email protected]"
m.Cc := "[email protected]"
fff=C:\picklist\materialistas\test.txt
Body =
(Join
<p>Buen dia...</p>
<p>Se ha creado un nuevo PickList para Almacen,esta es la informacion</p>
<p>ORDEN: %ORDEN%<br>FOLIO: %CONSECU%<br>QTY TOTAL ORDEN: %QTY%<br>Usuario: %SOLICITANTE%<br>KIT SIZE: %kitsize%<br>SUB ENSAMBLE: %SUBENSAMBLE%</p>
<p>Favor de dar seguimiento desde la aplicacion <a href="%fff%">ALMACEN</a></p>
<p>Si usted piensa que no deberia recibir esta informacion favor de comunicarlo a Hot Hot 85<br>Gracias.</p>
;attach pic
<img src="C:\mndisk\Ticket_Requisitor\pic.jpeg" alt="HTML5 Icon" style="width:28px;height:8px;">
)
m.HTMLBody := Body
m.Display ;t*o display the email message...and the really cool part, if you leave this line out, it will not show the window............... but the m.send below will still send the email!!!
m.Send ;to *automatically send and CLOSE that new email window...
I hopé it help
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
The first responders code requires outlook which isnt going to be possible. I tried the blat one too with this code and it was unsuccessful.
I get this screen for about a minute:
Then it goes away and no email was sent.
Any ideas?
Thanks for your help.
Code: Select all
SMTPServer := "smtp.gmail.com"
SMTPUsername := "[email protected]"
SMTPPassword := "mypassword"
F := "[email protected]"
To := "[email protected]"
Subject := "TEST1"
Body := "TEST1"
run, blat -noh2 -serverSMTP %SMTPServer% -u %SMTPUsername% -pw %SMTPPassword% -f %F% -to %To% -subject %Subject% -body %Body%
Any ideas?
Thanks for your help.
Re: Sending email with AHK
Not sure if this isn't outdated. Make up your mind if AHK could be connected to it:
[How To Send Emails From The Commandline In Windows (Without Extra Software)]
[How To Send Emails From The Commandline In Windows (Without Extra Software)]
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
I've come to the conclusion that Gmail requires SSL and none of these scripts or Blat support SSL.
I've been trying the fix with Stunnel\Blat but also looking into the script with mailsend.
One issue is that the file no longer exists where the script leads to. I downloaded a different version here:
https://github.com/muquit/mailsend/releases
I ran it manually with this command:
mailsend.exe -to "myemail" -from "myemail" -ssl -smtp smtp.gmail.com -port 465 -sub "subject" -M "emailMessage" -q -auth-plain -user "myemail" -pass "mypass" -attach "test.txt",, Hide
And I get this error: Still working on it, but if you can help let me know.
Thanks.
I've been trying the fix with Stunnel\Blat but also looking into the script with mailsend.
One issue is that the file no longer exists where the script leads to. I downloaded a different version here:
https://github.com/muquit/mailsend/releases
I ran it manually with this command:
mailsend.exe -to "myemail" -from "myemail" -ssl -smtp smtp.gmail.com -port 465 -sub "subject" -M "emailMessage" -q -auth-plain -user "myemail" -pass "mypass" -attach "test.txt",, Hide
And I get this error: Still working on it, but if you can help let me know.
Thanks.
Re: Sending email with AHK
Hey - im a bit late to the party here, but i use this to automatically send emails whenever a user creates a quote for our internal company use.
Works good for me - just fill in with your server info, etc.
Lemme know if you have questions!
Thanks!
Works good for me - just fill in with your server info, etc.
Code: Select all
pmsg := ComObjCreate("CDO.Message")
pmsg.From := "[email protected]"
pmsg.To := "[email protected]"
pmsg.BCC := "" ; Blind Carbon Copy, Invisible for all, same syntax as CC
pmsg.CC := "" ; [email protected], [email protected]
pmsg.Subject := "Subject"
;pmsg.TextBody := ""
pmsg.HtmlBody := "Body"
sAttach := QuotePath ; can add multiple attachments, the delimiter is |
fields := Object()
fields.smtpserver := "smtp server here" ; specify your SMTP server
fields.smtpserverport := 587 ; 25
fields.smtpusessl := False ; False
fields.sendusing := 2 ; cdoSendUsingPort
fields.smtpauthenticate := 1 ; cdoBasic
fields.sendusername := "xxxxxxxxxxxxx"
fields.sendpassword := "xxxxxxxx"
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()
Thanks!
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
I get this error. I believe since gmail requires SSL.
Don''t think that will work, unless I'm doing something wrong.Re: Sending email with AHK
Are you able to use another email client like Thunderbird? I just wrote up this very shoddy automatic email composer (doesn't send, because it doesn't use COM or anything, there's a chance of a typo).
Code: Select all
^7::
WinActivate, ahk_exe thunderbird.exe
Send ^n ; new email
WinWaitActive, Write: (no subject)
Sleep 250
Send !r ; gets to the fRom field
Sleep 250
Send {Down 10} ; scrolls to the bottom to prompt the dropdown to appear
Sleep 100
Send {End}{Up} ; selects the bottom option in the dropdown
Sleep 100
Send {Tab 3} ; moves to the To field
SendInput [email protected] ; the person I'm emailing
Sleep 100
Send {Tab} ; moves to the Title field
FormatTime, outputMcD, , MM/dd/yy
SendInput %outputMcD% ; provides a Title
Sleep 100
Send {Tab} ; Move to the Body
Sleep 100
Send My Name ; populate the Body
return
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
Unfortunately Thunderbird is not an option.
Furthermore, I'm really trying to avoid any use of sending commands in that fashion.
I am open to a command based email service like Blat if it uses SSL, Blat doesn't
Furthermore, I'm really trying to avoid any use of sending commands in that fashion.
I am open to a command based email service like Blat if it uses SSL, Blat doesn't
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: Sending email with AHK
Hi I'm also trying to something similar like you. I have found a PowerShell solution.
This scripts creates email.ps1, runs it and afterwards deletes the .ps1 file.
The only thing I'm personally not happy about is, that the login name / password are stored in
a file, which is a security issue. Even though the file is deleted one second after
execution.
Hope this helps:
This scripts creates email.ps1, runs it and afterwards deletes the .ps1 file.
The only thing I'm personally not happy about is, that the login name / password are stored in
a file, which is a security issue. Even though the file is deleted one second after
execution.
Hope this helps:
Code: Select all
#NoEnv
#Warn
#SingleInstance Force
SetBatchLines, -1
SendMode, Input
FileDelete, email.ps1
SMTPServer = "smtp.someprovider.com"
SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, 587)
SMTPClientEnableSsl = $true
SMTPClientCredentials = New-Object System.Net.NetworkCredential("[email protected]", "SomePassword");
EmailFrom = "[email protected]"
EmailTo = "[email protected]"
Subject = "NSA hacktool"
Body = "Hi Marc, I'm glad to inform you my NSA hacktool is ready"
FileAppend, $SMTPServer = %SMTPServer%`n, email.ps1
FileAppend, $SMTPClient = %SMTPClient%`n, email.ps1
FileAppend, $SMTPClient.EnableSsl = %SMTPClientEnableSsl%`n, email.ps1
FileAppend, $SMTPClient.Credentials = %SMTPClientCredentials%`n, email.ps1
FileAppend, $EmailFrom = %EmailFrom%`n, email.ps1
FileAppend, $EmailTo = %EmailTo%`n, email.ps1
FileAppend, $Subject = %Subject%`n, email.ps1
FileAppend, $Body = %Body%`n, email.ps1
FileAppend, $SMTPClient.Send($EmailFrom`, $EmailTo`, $Subject`, $Body)`n, email.ps1
run, powershell.exe -ExecutionPolicy Bypass -File email.ps1
Sleep, 1000
FileDelete, email.ps1
Re: Sending email with AHK
[brainfart]
You probably can save your password (slightly encrypted?) within the compiled scripts metadata or an AlternateDataStream. That way you wouldn't have to create an additional plain text file.
[/brainfart]
https://autohotkey.com/boards/viewtopic.php?t=27909
https://autohotkey.com/board/topic/6500 ... ript-file/
https://autohotkey.com/boards/viewtopic.php?t=5677
You probably can save your password (slightly encrypted?) within the compiled scripts metadata or an AlternateDataStream. That way you wouldn't have to create an additional plain text file.
[/brainfart]
https://autohotkey.com/boards/viewtopic.php?t=27909
https://autohotkey.com/board/topic/6500 ... ript-file/
https://autohotkey.com/boards/viewtopic.php?t=5677
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
This one isn't working for gmail either. The powershell opens, but it's not actually sending the email.WalkerOfTheDay wrote:Hi I'm also trying to something similar like you. I have found a PowerShell solution.
This scripts creates email.ps1, runs it and afterwards deletes the .ps1 file.
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: Sending email with AHK
I believe I had it working with gmail. What smtp port are you using?magicinmath wrote:This one isn't working for gmail either. The powershell opens, but it's not actually sending the email.WalkerOfTheDay wrote:Hi I'm also trying to something similar like you. I have found a PowerShell solution.
This scripts creates email.ps1, runs it and afterwards deletes the .ps1 file.
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
I've tried all of them available to gmail, but 465 is the recommended.
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: Sending email with AHK
For me it works in gmail with port 587.magicinmath wrote:I've tried all of them available to gmail, but 465 is the recommended.
edit
You might have to turn this on:
https://support.google.com/accounts/ans ... 0255?hl=en
edit2
Yes, above is the problem. When I turn it off, it doesn't work for me neither.
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
Thank you!
-
- Posts: 162
- Joined: 12 Apr 2017, 23:03
Re: Sending email with AHK
Is there anyway to include attachments to the email?
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: Sending email with AHK
Yes I think so. Haven't had the time to test it through.magicinmath wrote:Is there anyway to include attachments to the email?
Check below article.
https://social.technet.microsoft.com/Fo ... powershell
Who is online
Users browsing this forum: Descolada, Google [Bot] and 82 guests