Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 897

用命令行直接透過Gmail寄信,可以快速寄出電子書檔案給Kindle接收(AHK #8)

$
0
0

Windows有個COM物件可以很簡便的寄信,就是CDO (Collaboration Data Objects) 物件,如果我們使用AutoHotkey來操作CDO的話,可以用一行命令、很簡單的就能把電子書檔案寄出,不必再使用IFTTT.com或進入電子郵件應用程式。

#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()

實際的操作影片

##

您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 897

Trending Articles