3 replies
by andrew
Here's some code that opens the first mail item in the InBox, and copies the body text to a new Word doc and saves it:
'outlook
Dim oOutlook As Outlook.Application
Dim oInbox As Outlook.MAPIFolder
Dim oMail As Outlook.MailItem
'word
Dim oWord As Word.Application
Dim oDoc As Word.Document
'get the outlook mail data...
Set oOutlook = New Outlook.Application
Set oInbox = oOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set oMail = oInbox.Items.GetFirst
'create a word doc...
Set oWord = New Word.Application
Set oDoc = oWord.Documents.Add
oDoc.Range = oMail.Body 'copy the text in
oDoc.SaveAs "c:\test.doc"
'clean up....
Set oMail = Nothing
Set oInbox= Nothing
Set oOutlook = Nothing
Set oDoc = Nothing
Set oWord = Nothing
Hope this gets you started.
by mhimeda
by mhimeda
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending