使用PushBullet 寄發 outlook 信件通知
有時候公司信 外部不能收 , 亦或是作業環境關係不能時常檢查信件,
當收到新信件時,透過PushBullet 只將標題和寄件者提醒至手機上
更換 YOUR_ACCESS_TOKEN
取得方式請到 https://www.pushbullet.com/ > setting 取得API TOKEN
可以指定哪一個device 要接受此通知,帶入ID即可
' PushBullet MARCO 腳本 Ver 1.0 by henry' PushBullet YOUR_ACCESS_TOKENPrivate Sub Application_NewMailEx(ByVal EntryIDCollection As String)Dim objItemSet objItem = Session.GetItemFromID(EntryIDCollection)If objItem.MessageClass = "IPM.Note" ThenAutoForward objItemEnd IfEnd SubPrivate Sub AutoForward(ByVal objMail As MailItem)'Dim strFileName As StringDim fwMail As MailItem' Dim i As IntegerDim strSenderName As StringDim strSenderEmailAddress As StringDim strSubject As StringDim strbody As String'On Error GoTo ErrorTrap'' 標題、送信者、本文取得strSubject = objMail.Subject ' 標題取得strSenderName = objMail.SenderName ' 送信者取得strSenderEmailAddress = objMail.SenderEmailAddress ' Email取得strbody = objMail.Body ' 本文取得strbody = mid(strbody,0,100)'If strSenderName = strSenderEmailAddress ThenstrSenderName = strSenderEmailAddressElseIf InStr(strSenderEmailAddress, "@") ThenstrSenderName = strSenderName + "<" + strSenderEmailAddress + ">"ElsestrSenderEmailAddress = _objMail.Sender.PropertyAccessor.GetProperty("http://schemas." _& "microsoft.com/mapi/proptag/0x39FE001E")strSenderName = strSenderName + "<" + strSenderEmailAddress + ">"End IfEnd If'TargetURL = "https://api.pushbullet.com/v2/pushes"Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")HTTPReq.Option(4) = 13056 'HTTPReq.Open "POST", TargetURL, FalseHTTPReq.SetCredentials "user", "password", 0HTTPReq.setRequestHeader "Authorization", "Bearer YOUR_ACCESS_TOKEN"HTTPReq.setRequestHeader "Content-Type", "application/json"Message = "{""type"": ""note"", ""title"": " & _vbDoubleQuote & strSubject & vbDoubleQuote & ", ""body"": " & _vbDoubleQuote & strbody & vbDoubleQuote & "}"HTTPReq.Send (Message)' delete this line once you are happy it works. Or put in some proper error handling!MsgBox (HTTPReq.responseText)'ErrorTrap:'End Sub