Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-10
6
Medium Priority
?
357 Views
Last Modified: 2013-11-25
How to access Outlook folders, items and fields from Visual Basic?? :-)
0
Comment
Question by:liudan
6 Comments
 
LVL 5

Expert Comment

by:Cimperiali
ID: 8109557
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
 

Author Comment

by:liudan
ID: 8737408
NO,I will access Outlook folders, items and fields from Visual Basic Without "MAPI".  :-)
0
 
LVL 5

Expert Comment

by:Cimperiali
ID: 8756095
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:CleanupPing
ID: 8900349
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 9074771
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9166055
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question