Const vbDoubleQuote As String = """" 'represents 1 double quote (")
Const vbSingleQuote As String = "'" 'represents 1 single quote (')
Private WithEvents myOlItems As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set myOlItems = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal item As Object)
Dim Msg As Outlook.MailItem
Dim Title As String
Dim Body As String
Dim Message As String
Set Msg = item
Title = Msg.Subject
Body = Msg.Body
TargetURL = "https://api.pushbullet.com/v2/pushes"
Set HttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
HttpReq.Option(4) = 13056
HttpReq.Open "POST", TargetURL, False
HttpReq.SetCredentials "user", "password", 0
HttpReq.setRequestHeader "Authorization", "Bearer myAPI"
HttpReq.setRequestHeader "Content-Type", "application/json"
Message = "{""channel_tag"": ""myChannel"", ""type"": ""note"", ""title"": " & _
vbDoubleQuote & Title & vbDoubleQuote & ", ""body"": " & _
vbDoubleQuote & Body & vbDoubleQuote & "}"
HttpReq.Send (Message)
大家好,很抱歉,如果這個問題對你們來說太簡單了,但我對此一無所知。字符串不會出現在定義
以上是我的代碼,一旦在消息我把標題改爲了我必須在代碼中定義:
(""title"": " & _
vbDoubleQuote & Title & vbDoubleQuote & ") as "Title = Msg.Subject".
但仍然在推什麼,但空消息沒有任何消息,只是一個空的消息。
我錯誤地定義了字符串嗎?
在'HttpReq.Send'行之前添加'Debug.Print Message'並在直接窗口中查看它。它看起來正確嗎? – Comintern
嗨@Comintern,感謝您的幫助,在添加該行後,郵件根本沒有推送到我的PushBullet。 我注意到,當我在「Set Msg = item」後面定義一些東西時 代碼停止推送.. – Sap1