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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript/Outlook 2000 Question

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
US
Hello again people,

Does anyone know how to extract a line of information from the body of an email in Outlook and place it in a targeted cell in an Excel worksheet? I'm trying to piece together a macro, but no dice so far =P

Thanks,
Jisoo22
 
'This code should show you how to access Outlook 2000 and retrieve some data. Use defaultfolder #6 and go to the message body to retrieve the line.

Do you know how to open an Excel app via vbscript?


Set appOutl = Wscript.CreateObject("Outlook.Application")
Set objSession = appOutl.GetNameSpace("MAPI")
objSession.Logon Profile_Name_Here

' 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
MsgBox MyItems(I).body
Next

' *** Contacts Folder
Set MyFolder = objSession.GetDefaultFolder(10)
Msgbox MyFolder.name & ", " & MyFolder.Items.Count
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
For I = 1 to MyFolder.Items.Count
MsgBox MyItems(I).FullName
Next
 
This example helps quite a bit, but how do I call a Macro in Outlook from Excel?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top