> Don't get me wrong; you can freely use and modify the code provided on my
> webpage but when you are going to repost it publicly, there are better and
> more proper ways to do so. Not properly separating the reference and your
> own contribution is considered plagiarism.
>
I certainly didn't mean to plagiarize (thus the reference to your
original work). Without your original work I wouldn't have figured
out the solution to my problem. I spent a few hours last night
searching and your website was the only thing even close. Telling
users to open the mail, click other actions, and then select view in
browser was a non-starter. Your code opened the email in IE but
apparently used Word Formatting because the buttons were still not
active.
Do you have a reference for how to properly quote original
code?? I'm searching the etiquette posts but haven't seen anything.
The slightly cleaned up code(hopefully, correctly annotated) is
below. I apologize.
Sub OpenInBrowser()
'This procedure was written by Robert Spaarnaaij
'and may be found at
http://www.howto-outlook.com/openinbrowser.htm
'Several lines have been added to save the html from the email.
'The original used file saveas
Dim BrowserLocation As String
'Dim Response As Integer
'Set the location of the executable of the browser you want to use
BrowserLocation = "C:\Program Files\Internet Explorer
\iexplore.exe"
'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
Dim MySelectedItem As MailItem 'added declaration to make MySelected
Item a MailItem object
'Retrieve the selected item
Set MySelectedItem = MyOlselection.item(1)
Dim sHTML As String 'Added string variable to hold the HTMLBody
'apparently the original code saved the file in Word Format
sHTML = MySelectedItem.HTMLBody 'Added to place the HTML from the
email into the temp file
'save the selected item as htm to the temp folder
strname = "www_howto-outlook_com"
FileName = FileName & "\" & strname & ".htm"
'The following line was in the original code - it was replaced
with code for saving
'the HTML
MySelectedItem.SaveAs FileName, olHTML
Dim SaveFile As Object 'added for use in saving the HTML file
'Added next 7 lines to write and save the HTML file
If FSO.fileexists(FileName) Then
Set SaveFile = FSO.OpenTextFile(FileName, 2, False)
Else
Set SaveFile = FSO.OpenTextFile(FileName, 2, True)
End If
SaveFile.Write sHTML
SaveFile.Close
'open the saved item in the browser
Shell BrowserLocation & " " & FileName, vbNormalFocus
'Cleanup
Set FSO = Nothing
Set FileName = Nothing
Set MyOlNamespace = Nothing
Set MyOlselection = Nothing
Set MySelectedItem = Nothing
Set SaveFile = Nothing 'Added
End Sub