Outlook:如何使用VBA将所选邮件发布到Web服务器? [英] Outlook: How do I POST the selected message to a web server using VBA?

查看:197
本文介绍了Outlook:如何使用VBA将所选邮件发布到Web服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:在Outlook工具栏中有一个按钮,当按下该按钮时,将完整的当前消息(可能是.msg文件)通过post发送到URL。必须在此过程中打开某种浏览器窗口,以便用户可以在URL输入应用程序的登录详细信息(除非我能以某种方式解决这个问题,想法?)。



<我已经创建了一个VBA宏并在Outlook 2007中为它添加了一个按钮(虽然我也需要它在Outlook 2003中也可以,至少)。



我已经阅读了VBA FollowHyperlink方法,但我无法让小VBA宏IDE识别它(Application.FollowHyperlink和其他几个尝试都给出了错误)。



(我是VBA新手的.Net程序员,所以如果在VB.NET或C#中有一种更简单的方法,那么一定要指向正确的方向) 。



想法?

解决方案

以下是我的概述认为它应该有效。




  • 对于通信,请使用a WinHttp.WinHttpRequest.5 COM对象(调查 FollowHyperlink()将毫无意义)。此对象可以执行您可以想到的任何形式的HTTP请求。在Outlook VBA项目中引用它以获取Intellisense和早期绑定。

  • 对于用户名和密码,创建一个带有两个文本框的小型自定义表单。您甚至可以使用该表单来缓存用户名和密码(当表单不在视图范围内时调用隐藏 - 将保留所有表单级别变量,以便您可以再次使用它们。)

  • 要准备有效负载,请使用此方法( KB240935 )获取当前选定的项目,检查它的类型(如果TypeOf currentItem是MailItem然后...... ),并调用 SaveAs()将其保存为.msg在临时文件夹中。将它附加到准备好的POST请求中,你就可以了。

  • 对于用户界面,在自定义 CommandBar中放置一个按钮(您甚至可以在应用程序启动时以编程方式创建一个)。将按钮链接到普通VBA模块中的 Public Sub 。在此 Sub 中,确定是否需要 Show()您的自定义用户名/密码对话框,或者是否存在缓存凭据,并进行必要的HTTP请求处理。



祝你好运!它不应该太复杂。


Goal: To have a button in the Outlook toolbar which, when pressed, sends the current message in it's entirety (perhaps as a .msg file) via post to a URL. Some kind of browser window must be opened in the process so the user can enter login details for the application at the URL (unless I can get around this somehow, thoughts?).

I have created a VBA Macro and put a button for it in Outlook 2007 (though I'll need this to work in Outlook 2003 too, at least).

I've read about the VBA FollowHyperlink method, but I can't get the little VBA Macro IDE to recognise it (Application.FollowHyperlink and several other attempts gave errors).

(I'm a .Net programmer new to VBA, so if there is a simpler way in VB.NET or C# by all means point me in the right direction).

Ideas?

解决方案

Here is an outline of how I think it should work.

  • For the communication, use the a "WinHttp.WinHttpRequest.5" COM object (investigating FollowHyperlink() will be pointless). This object can do any form of HTTP request you can think of. Reference it in the Outlook VBA project to get Intellisense and early binding.
  • For username and password, create a tiny custom form with two text boxes. You can even use that form to cache username and password (call "Hide" when the form should go out of view - all form level variables will be retained so you can use them again).
  • For preparing the payload, use this method (KB240935) to get the currently selected item, check it for type (If TypeOf currentItem Is MailItem Then ...), and call SaveAs() to save it as .msg in a temporary folder. Attach it to your prepared POST request, and you are good to go.
  • For the user interface, put a button in a custom CommandBar (you can even create one programmatically at Application start). Link the button to a Public Sub in an ordinary VBA module. In this Sub, decide if you need to Show() your custom username/password dialog, or if cached credentials exist, and do the necessary HTTP request handling.

Good luck! It should not be too complicated.

这篇关于Outlook:如何使用VBA将所选邮件发布到Web服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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