How to access outlook folders ,items and fields from Visual Basic ??

How to access Outlook folders, items and fields from Visual Basic?? :-)
liudanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CimperialiCommented:
For example...
'reference msoutl85.olb
Private objOutlook As Outlook.Application
Dim objMapi As NameSpace
Dim curInbox As Outlook.MAPIFolder
Dim MailItem As Variant 'needed as not all items are of "MailItem" type...
'.....
Screen.MousePointer = vbHourglass
'....Instance to OutLook
Set objOutlook = New Outlook.Application
'....INstance namespace
Set objMapi = objOutlook.GetNamespace("MAPI")
'..start getting inbox folder:
Set curInbox = objMapi.GetDefaultFolder(6)
'...get mails
For Each MailItem In curInbox.Items
   DoEvents 'you mau have a lot...do not hang pgm
   If TypeOf MailItem Is Outlook.MailItem Then
      'This is a mailitem. You can for example, get the subject
      'Here we add it to a listBox control
      'in conjunction with the EntryId of the mail, to be able to
      'reach the item when needed with a single shot
      List1.AddItem MailItem.EntryID & " " & MailItem.Subject
    ElseIf TypeOf MailItem Is Outlook.MeetingItem Then
      'This is a "Meeting Item". It has some fields less
      'you can retrieve the subject in any case, and here
      'we add it to another listBox control:  
      List2.AddItem "Meeting Item: " & MailItem.Subject
      MailItem.Close olDiscard
    End If
 
Next MailItem
Set MailItem = Nothing
Set curInbox = Nothing
Set objMapi = Nothing
objOutlook.Quit
Set objOutlook = Nothing
Screen.MousePointer = vbDefault
0
liudanAuthor Commented:
NO,I will access Outlook folders, items and fields from Visual Basic Without "MAPI".  :-)
0
CimperialiCommented:
With Cdo or Cdonts?...but I am not sure you can gain access to Outlook folders and items this way. You could parse a *.pst file, but it may not be one on client machine, as the items may still be on a server...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

CleanupPingCommented:
liudan:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
DanRollinsCommented:
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
YensidModCommented:
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.