V
Vampyr_Bytes
Hi there,
I'm trying to get the body of html emails into a word document. I can get the
contents over as either plain text or html code, but cannot figure out how to
get it across formatted. The code I'm using is below. Any and all help is
greatly appreciated.
Sub SendToWord()
Dim objFolder As MAPIFolder
Dim objEmail As MailItem
Dim objDoc As Word.Document
Dim objWord As Word.Application
Dim Count As Integer
Dim i As Integer
'Getting outlook inbox folder
Set objFolder = Application.ActiveExplorer.CurrentFolder
'Total number of mails in the inbox
Count = objFolder.Items.Count
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
objDoc.Activate
i = 0
While i < Count
i = i + 1
With objFolder.Items(i)
objWord.Selection.TypeText .Body
objWord.Application.Run ("GetDetails")
End With
Wend
objWord.Quit savechanges:=False
End Sub
That gives the plain text. If I use objWord.Selection.TypeText .HTMLBody I
get the html code.
Thanks in advance
I'm trying to get the body of html emails into a word document. I can get the
contents over as either plain text or html code, but cannot figure out how to
get it across formatted. The code I'm using is below. Any and all help is
greatly appreciated.
Sub SendToWord()
Dim objFolder As MAPIFolder
Dim objEmail As MailItem
Dim objDoc As Word.Document
Dim objWord As Word.Application
Dim Count As Integer
Dim i As Integer
'Getting outlook inbox folder
Set objFolder = Application.ActiveExplorer.CurrentFolder
'Total number of mails in the inbox
Count = objFolder.Items.Count
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
objDoc.Activate
i = 0
While i < Count
i = i + 1
With objFolder.Items(i)
objWord.Selection.TypeText .Body
objWord.Application.Run ("GetDetails")
End With
Wend
objWord.Quit savechanges:=False
End Sub
That gives the plain text. If I use objWord.Selection.TypeText .HTMLBody I
get the html code.
Thanks in advance