Created
September 29, 2019 07:15
-
-
Save emisjerry/f655fe397259bf65dee33a80833b049f to your computer and use it in GitHub Desktop.
用命令行直接透過Gmail寄信,可以快速寄出電子書檔案給Kindle接收(AHK #8)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance Force | |
sFileName := A_Args[1] ;; 傳入參數必須帶有路徑 | |
if (sFileName = "") { | |
MsgBox 必須傳入完整檔名 | |
return | |
} | |
pmsg := ComObjCreate("CDO.Message") | |
;;pmsg.Charset := "UTF-8" | |
pmsg.From := """SendByAHK"" <你的Gmail帳號@gmail.com>" | |
pmsg.To := "你的Kindle帳號@kindle.com" | |
pmsg.BCC := "" ; Blind Carbon Copy, Invisable for all, same syntax as CC | |
pmsg.CC := "" | |
pmsg.Subject := "傳送Kindle檔名:" . sFileName | |
;You can use either Text or HTML body like | |
pmsg.TextBody := "傳送檔名:" . sFileName | |
;OR | |
;pmsg.HtmlBody := "<html><head><title>Hello</title></head><body><h2>Hello</h2><p>Testing!</p></body></html>" | |
;;MsgBox %sFileName% | |
sAttach := sFileName ; 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 := "你的Gmail帳號@gmail.com" | |
fields.sendpassword := "你的Gmail帳號密碼" | |
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() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment