Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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



Edit: 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>



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?
Posted
Updated 23-Mar-12 14:35pm
v3
Comments
ZurdoDev 23-Mar-12 15:28pm    
What do you have so far? Please share some of the code so we can help.
Nelek 23-Mar-12 20:37pm    
Please, don't answer yourself just to add code or make comments to answer another person.

use the "Improve question" at the right side below you message and add it to the original post.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900