Last active
October 5, 2021 00:39
-
-
Save niwa-tt/a2dae4588713929b46c0059c9cd17648 to your computer and use it in GitHub Desktop.
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
' | |
Dim WithEvents mySentItems As Items | |
' | |
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) | |
Set mySentItems = Session.GetDefaultFolder(olFolderSentMail).Items | |
End Sub | |
' | |
Private Sub mySentItems_ItemAdd(ByVal Item As Object) | |
If TypeName(Item) = "MailItem" Then | |
Dim objMail As MailItem | |
Set objMail = Item | |
TargetURL = "https://hooks.slack.com/services/..." | |
Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1") | |
HTTPReq.Open "POST", TargetURL, False | |
HTTPReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" | |
Dim sendText As String | |
sendText = "payload={""text"":""件名: " & objMail.Subject & "\n本文: " & Left(objMail.Body, 200) & """}" | |
HTTPReq.Send (sendText) | |
objMail.Close olSave | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment