open message in web browser

P

PJB

I have closely followed the creation instructions from "how-to-outlook' in
order to view gif animations in Outlook 7. However when running it I get the
following error message, marked by me between brackets (THIS IS THE ERROR) in
the complete VB-script. What is wrong/have I done wrong? I use windows 7
64-bit.
Any suggestions please!


Sub OpenInBrowser()

Dim BrowserLocation As String
Dim AlwaysConvert As Boolean
Dim EvaluateHTML As Boolean

'=============Set your variables in the section
below==========================
'The default settings are optimized for viewing newsletters and receiving
'messages with HTML forms or animated gif-files embedded in the message.

'Set the location of the executable of the browser you want to use.
'Standard value: "C:\Program Files(x86)\Internet Explorer\iexplore.exe"
BrowserLocation = "C:\Program Files(x86)\Internet Explorer\iexplore.exe"

'When set to True, we will let Outlook convert the message to HTML.
'The message will be opened in the configured browser just as it
'appears in Outlook.
'Standard value: False
AlwaysConvert = False

'When set to True, we will look for embedded resources in the HTML
message and
'determine whether Outlook should convert the message or whether we can
strip
'the HTML directly. When set to False, we will always strip the HTML and
ignore
'embedded resources.
'For this setting to take effect, AlwaysConvert must be set to False.
'Standard value: True
EvaluateHTML = True

'=======Don't modify the code below unless you know what you are
doing=========

'Get the user's TempFolder to store the item in
Dim FSO As Object, TmpFolder As Object
Set FSO = CreateObject("scripting.filesystemobject")
Set FileName = FSO.GetSpecialFolder(2)

'Get all selected items
Dim MyOlNamespace As Outlook.NameSpace
Set MyOlNamespace = Application.GetNamespace("MAPI")
Set MyOlSelection = Application.ActiveExplorer.Selection

'Make sure at least one item is selected
If MyOlSelection.Count = 0 Then
Response = MsgBox("Please select an item first", vbExclamation,
MyApplName)
Exit Sub
End If

'Make sure only one item is selected
If MyOlSelection.Count > 1 Then
Response = MsgBox("Please select only one item", vbExclamation,
MyApplName)
Exit Sub
End If

'Retrieve the selected item
Set MyselectedItem = MyOlSelection.Item(1)

'construct the filename
strname = "www_howto-outlook_com"
FileName = FileName & "\" & strname & ".htm"

'If the message is in HTML format we directly capture the HTML from the
message
'to construct our htm-file. This will allow us to capture as many HTML
elements
'as possible. If it is a different format, or if the HTML mail includes
embedded
'resources we let Outlook convert it to HTML.
Dim OutlookConvert As Boolean
OutlookConvert = True

If MyselectedItem.BodyFormat = olFormatHTML And AlwaysConvert = False Then
Dim rawHTML As String
rawHTML = MyselectedItem.HTMLBody

If EvaluateHTML = False Then
OutlookConvert = False
Else
'Check if there are embedded resources in the message.
'If it does, we let Outlook convert the message.
If InStr(UCase(rawHTML), UCase("src=""cid:")) = 0 Then
OutlookConvert = False
End If
End If
End If

'Write the temp-file
If OutlookConvert = False Then
'create the htm-file in the temp folder and write the HTML code
to it
Set objFile = FSO.CreateTextFile(FileName, True)
objFile.Write "" & rawHTML
objFile.Close
Set objFile = Nothing
Else
'let Outlook convert the message and save the selected item
'as htm to the temp folder
MyselectedItem.SaveAs FileName, olHTML
End If

'open the saved item in the browser
Shell BrowserLocation & " " & FileName, vbNormalFocus (THIS IS THE
ERROR!!)

'Cleanup
Set FSO = Nothing
Set FileName = Nothing
Set MyOlNamespace = Nothing
Set MyOlSelection = Nothing
Set MyselectedItem = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top