通过Outlook中的VBScript规则调用Slack API [英] Call Slack API via VBScript Rule in Outlook

查看:104
本文介绍了通过Outlook中的VBScript规则调用Slack API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在运行VBScript的Outlook中运行一条规则,该规则调用Slack.com Web服务并使用特定消息更新我的Slack频道之一.当前状态-我只希望它发布静态消息.将来的状态,我将尝试使用RegEx从电子邮件中解析出某些数据并将其发布到我的闲暇频道.

I'm trying to run a rule in Outlook that runs a VBScript which calls a Slack.com webservice and updates one of my Slack Channels with a specific message. Current state -- i just want it to post a static message. Future state i'm going to try to use RegEx to parse out certain data from the email and post it to my slack channel.

根据我在网上发现的一些脚本进行的科学怪人检查,这就是我所拥有的(但效果不佳),希望有人可以提供帮助...

From frankensteining a few scripts i found online, this is what i have (but doesn't quite work) Hoping someone can help...

    Function ProcessSend()
    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
    Set oXMLDoc = CreateObject("MSXML2.DOMDocument")

    strEnvelope = "payload={""channel"": ""#edt-error"", ""text"": ""This is posted to #edt-error.""}"

    Call oXMLHTTP.Open("POST", "https://custom-slack-url-for-service-goes-here.com" & 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)

    If (oXMLDoc.parseError.ErrorCode <> 0) Then
        'call msgbox("ERROR")
        response = oXMLHTTP.responseText&" "&oXMLDoc.parseError.reason
        'call msgbox(oXMLDoc.parseError.reason)
    Else
        response = oXMLDoc.getElementsByTagName("string")(0).ChildNodes(0).Text
    End If
End Sub

推荐答案

所以我自己解决了这个问题,但想发布更多详细信息.

So I resolved this myself, but wanted to post more details.

请求::我想打电话给Slack并用自定义消息更新我的频道之一,当我收到电子邮件并触发Outlook规则时(从X发送给Y的消息)

Request : I want to make a call to Slack and update one of my channels with a custom message WHEN I receive an email and an Outlook rule is triggered (message from X and sent to Y).

解决方案:首先,您需要导航到C驱动器上Microsoft Office文件夹中的selfcert.exe,创建一个新的自签名证书,然后将该证书添加到以下位置的Trusted Publishers外表.完成后,我通过按Alt + F11从Outlook中打开Visual Basic,并在"ThisOutlookSession"项目中创建了以下脚本.

Solution : First off, you need to navigate to selfcert.exe in your Microsoft Office folders on the C drive, create a new self-signed certificate, and then add that certificate to Trusted Publishers in Outlook. AFTER that's done, I opened Visual Basic from Outlook by pressing Alt+F11 and created the following script in the "ThisOutlookSession" project.

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

    strEnvelope = "payload={""channel"": ""#edt-error"", ""text"": ""This is posted to #edt-error.""}"

    Call oXMLHTTP.Open("POST", "https://INSERT-YOUR-SERVICE-URL-HERE" & 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

最后,我创建了一个规则,该规则寻找适当的参数,然后执行运行此脚本"操作.单击规则中的脚本"名称时,将弹出一个窗口,您可以选择已经创建的上述脚本.

Finally I created a rule that looked for the appropriate parameters and then peformed a "Run this script" action. When you click on the "script" name in the rule, a window will popup and you can select the above script you already created.

希望这对某人有帮助!

这篇关于通过Outlook中的VBScript规则调用Slack API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆