Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a Outlook Email into a file

Status
Not open for further replies.

Leighton21

Technical User
Dec 17, 2001
83
AU
Hi All,

Does anyone know of a function that could be used to read the contents of a Outlook Email and write it to a file. I basically want to read an email and write some of the words in the body of the email to a text file. I think I could use the ActiveExplorer method to read the current email, however I am not sure what to use to read the body of the email and save it to a file.

Regards

Leighton21
 
Leighton21,

Try this.

fengshui_1998


' Create a session and log on, use a valid exchange profile name
'
Set appOutl = Wscript.CreateObject("Outlook.Application")
Set objSession = appOutl.GetNameSpace("MAPI")
' objSession.Logon ("yourLogonHere")

' 3 = "Deleted Items"
' 4 = "Outbox"
' 5 = "Sent Items"
' 6 = "Inbox"
' 9 = "Calendar"
' 10 = "Contacts"
' 11 = "Journal"
' 12 = "Notes"
' 13 = "Tasks"
' 15 = "Reminders"
' 16 = "Drafts"

' *** INBOX folder
Set MyFolder = objSession.GetDefaultFolder(6)
Msgbox MyFolder.name & ", " & MyFolder.Items.Count

' Set MyItem to the collection of items in the folder.
Set myItems = myFolder.Items
' Loop through all of the items in the folder.
For I = 1 to MyFolder.Items.Count
MsgBox MyItems(I).subject & " : " & MyItems(I).body
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top