Skip to content

Instantly share code, notes, and snippets.

@jyukutyo
Created February 20, 2015 05:58
Show Gist options
  • Save jyukutyo/044a5cb579e86f16ad8d to your computer and use it in GitHub Desktop.
Save jyukutyo/044a5cb579e86f16ad8d to your computer and use it in GitHub Desktop.
post mail body by http request
Option Explicit
Const BOT_URL = "http://example.com"
Public Sub Run(Item As Outlook.MailItem)
Say (Item.Body)
End Sub
'==================================================
'UrlEncodeUtf8: 文字列をUTF-8でエンコードするFunction
'==================================================
'strSource: 元の文字列
'返り値: エンコードされた文字列
'==================================================
Public Function UrlEncodeUtf8(ByRef strSource As String) As String
Dim objSC As Object
Set objSC = CreateObject("ScriptControl")
objSC.Language = "Jscript"
UrlEncodeUtf8 = objSC.CodeObject.encodeURIComponent(strSource)
Set objSC = Nothing
End Function
Sub Say(Body As String)
Dim xhr
Dim RequestURL As String
Dim Message As String
Message = Body
RequestURL = BOT_URL & "?m=" & UrlEncodeUtf8(Message)
Set xhr = CreateObject("Microsoft.XMLHTTP")
xhr.Open "GET", RequestURL, False
xhr.Send
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment