Discussion Locked

Outlook 2000 and OLE

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Any experienced MS Office developers out there that have worked with Outlook 2000 mail objects. We're trying to use the MS Office object model to pull content from a mail object and "paste" to another application like MS Word, Notepad, or WordPad as seamlessly as possible for the user.

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.

This discussion is closed to new replies.