open message in web browser

Status
Not open for further replies.
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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
G Can't open .pst. Message could not access default folder (Outlook 2010 (.pst). Before that was backi Using Outlook 0
Diane Poremsky Open All Hyperlinks in a Email Message Using Outlook 0
S How can I Customize Message Header in both Reading Pane and Open Message Design? Using Outlook 1
I jump to body in open message with one keyboard shortcut? Using Outlook 3
I could not open attached files, i receive a message with “corrupted file” Using Outlook 0
C Open message is stuck minimized -Odd behavior when replying to a message(2010) Using Outlook 1
A Exception message: MapiExceptionLogonFailed: Unable to open message store Exchange Server Administration 1
A Macro - Open new message, populate from and subject fields, and message text Outlook VBA and Custom Forms 1
V "A program has attachment filename open" Message returns Outlook VBA and Custom Forms 4
Y message attachment saved by Outlook.Attachment.SaveFileAs not open Outlook VBA and Custom Forms 7
T Outlook 2021 Cannot open attachments Outlook DeskTop 2021 Using Outlook 0
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
talla Can't open Outlook Item. Using Outlook 0
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
K Embedded photos no longer open with Photos or Photo Viewer Using Outlook 7
witzker Open Contact missing in Outlook 2019 Using Outlook 2
L Cannot open PST file for first session each day Using Outlook 6
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
W Automatically open attachments without automatically printing them Using Outlook 0
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
C Can't Open Outlook 365 Using Outlook 0
D after delete mail, open the next one Outlook VBA and Custom Forms 0
M outlook won't open! Using Outlook 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
M other user's mailbox won't open, forms disappeared Using Outlook 42
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D Add Tetxbox at form open Outlook VBA and Custom Forms 1
U Catching ModuleSwitch events after "open in new window" Outlook VBA and Custom Forms 2
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
S Reminder Dialog Open Button Using Outlook 2
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
S Outlook 2010 Cannot Open Attachments Using Outlook 14
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A open Outlook with multiple windows. Using Outlook 0
K open calendar from address book Outlook VBA and Custom Forms 1
T Double clik behavior on agenda open a new meeting request Using Outlook 1
E Open olNoteItem Attachment Outlook VBA and Custom Forms 6
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item Using Outlook 0

Similar threads

Top