PDA

View Full Version : Email body to html file.



ukdane
03-30-2009, 12:41 PM
Here's the situation:

The user sends an email with an "idea" in the body.
The email is sorted (using a message rule) into a folder.

I then need some code that will automatically extract the body (minus any signature) and place the extracted text into an html file, or other program such as word or excel (but not override any existing text), that can then "show" the result on a webpage (so it needs to be converted to HTML in the end).

Thanks for your help.

joms
03-31-2009, 03:03 AM
hi ukdane, this might give you an idea to accomplish your task.. it will save the whole e-mail to HTML..but doesn't extract..


Sub SaveAsHMTL()
Dim myItem As Outlook.Inspector
Dim objItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the item? If a file with the same name already exists, it will be overwritten with this copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs "C:\" & strname & ".html", olHTML
End If
Else
MsgBox "There is no current active inspector."
End If
End Sub