Skip to content

Instantly share code, notes, and snippets.

@niwa-tt
Last active October 5, 2021 00:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niwa-tt/a2dae4588713929b46c0059c9cd17648 to your computer and use it in GitHub Desktop.
Save niwa-tt/a2dae4588713929b46c0059c9cd17648 to your computer and use it in GitHub Desktop.
'
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