1

I have the following to post static text. Call Slack API via VBScript Rule in Outlook

How would I put the body of the email as the "text"?

I tried adding the following:

Sub ProcessSend(Item As Outlook.MailItem)
    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
    Set oXMLDoc = CreateObject("MSXML2.DOMDocument")

    dim bodymsg as string
    bodymsg = mailitem.body

    strEnvelope = "payload={""channel"": ""#general"", ""username"": ""Help!"", ""text"": bodymsg ""Hello @general, sorry I don't have a room number for you yet!"", ""icon_emoji"": "":PartyParrot:""}"

    Call oXMLHTTP.Open("POST", "https://hooks.slack.com/services/customidnumberurlblabla" & posFirm, False)
    Call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    Call oXMLHTTP.Send(strEnvelope)

    Dim szResponse: szResponse = oXMLHTTP.responseText
    Call oXMLDoc.LoadXML(szResponse)
End Sub
Community
  • 1
  • 1
Marcus Lee
  • 31
  • 3

1 Answers1

2

Turns out I just needed to do the following:

Sub ProcessSend(Item As Outlook.MailItem)
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")

strEnvelope = "payload={""channel"": ""#general"", ""username"": ""Help!"", ""text"": ""@general" & Item.Body & """, ""icon_emoji"": "":PartyParrot:""}"

Call oXMLHTTP.Open("POST", "https://hooks.slack.com/services/blablablablablabla" & posFirm, False)
Call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call oXMLHTTP.Send(strEnvelope)

Dim szResponse: szResponse = oXMLHTTP.responseText
Call oXMLDoc.LoadXML(szResponse)
End Sub

Thanks for your help anyway.

Cheers, Marcus

Marcus Lee
  • 31
  • 3