包含正文的构建URL [英] Build URL containing body text

查看:117
本文介绍了包含正文的构建URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从供应商处收到一些单行电子邮件.
即备份会话完成".

我想在这些到达时打开一个URL,并且该URL应该包含电子邮件的正文,即:

http://server3/alertme/alertme.asmx/?alert = Tony& body = Backup Session Complete& user = alertme

我已经建立了规则,但无法弄清楚如何在URL中包含电子邮件的正文.

最终,我想包括HTML正文;但是文字很好.

电视



在此处从OP-Answer中添加代码

I receive some one line emails from a supplier.
i.e. "Backup session complete".

I want to open a URL when these arrive, and the url should contain the body of the email, ie:

Http://server3/alertme/alertme.asmx/?alert=Tony&body=Backup Session Complete&user=alertme

I have the rule built, but can''t figure out how to include the body of the email in the URL.

Ultimately, I''d like to include the HTML body; but text is fine.

TV



Adding code from OP-Answer here

Sub InstantiateInternetExplorer()

Dim objIE

Set objIE = CreateObject("internetexplorer.application")
objIE.Navigate URL:="http://server3/alertme/alertme.asmx?alert=<insert body="" text="">&alert=Tony&user=alertme" objIE.Visible = True

End Sub


''for ThisOutlookSession module
 Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
    Dim olApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Set olApp = Outlook.Application
    Set objNS = olApp.GetNamespace("MAPI")
    Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal item As Object) 
    If TypeName(item) = "MailItem" Then
        InstantiateInternetExplorer
    End If
End Sub
</insert>




以及其他一些评论:

消息是恒定的,主题是一个特殊的代码,它使我能够调节哪些消息到达规则.

而且由于它是一种API,因此如果出现错误消息,警报将失败.




And some other comments:

The messages are constant and the subject is a particular code that allows me to regulate what messages get through to the rule.

And since it''s an API, if, perhaps a bad message came in- the alert would fail.

Is it as simple as just putting message.bodytext in place of my brackets or not?

推荐答案

从理论上讲,这很简单-您所要做的一切是HTML编码的文本主体,并将其添加为示例中的参数.甚至还有一种方法可以帮助您做到这一点: HttpServerUtility.UrlEncode [ http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html [
In theory, it''s pretty simple - all you have to do is HTML encode the text body and add it as a parameter as in your example. There is even a method to help you do it: HttpServerUtility.UrlEncode[^]

However, it is probably a bad idea, and very likely to be a very, very bad idea. The problem is that the maximum length of a URL (including parameters) is not specified:

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.
(HTTP specification: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html[^])

The situation in the real world is more complex: it depends on the browser and other systems. For example, IE8''s maximum URL length is 2083 chars, and it seems IE9 has a similar limit, but earlier versions had a limit of about 2000.

Dangerous! If at all possible, I would find another way to do this, especially if the content of the message you are going to add is outside your control.


这篇关于包含正文的构建URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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