View Single Post
  #4  
Old November 5th 07, 05:48 PM posted to microsoft.public.outlook.program_vba
JP[_2_]
external usenet poster
 
Posts: 18
Default Extracting info from an Outlook email

Hello,

Here's some sample code I use in Excel to play around with email
properties. You could easily adapt this to do what you want.


Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olInbox As Outlook.MAPIFolder
Dim Item As Outlook.MailItem

Set olApp = GetObject(, "outlook.application")
Set olNS = olApp.GetNamespace("MAPI")
Set olInbox = olns.GetDefaultFolder(olFolderInbox)

If olInbox.UnReadItemCount 0 Then
For Each Item In olInbox.Items.Restrict("[Unread] = True")
MsgBox olInbox.UnReadItemCount & "unread emails"
Msgbox "To: " & Item.To
Msgbox "From: " & Item.SenderName
Msgbox "Subject: " & Item.Subject
Msgbox "Body: " & Item.body
Next Item
Else
MsgBox "No new/unread emails", vbInformation
End If

'destroy
Set olInbox = Nothing
Set olNS = Nothing
Set olApp = Nothing


HTH,
JP


On Nov 3, 9:23 am, Rob wrote:
I want to automatically extract the body of an incoming email and export the
result to a database or spreadsheet. Similar functions are available through
tools such as Mailbag Assistant for Outlook Express and other email programs.
Is there a way to do this with Microsoft Outlook?
--
Rob



Ads