?
Solved

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

Posted on 2003-03-10
6
Medium Priority
?
356 Views
Last Modified: 2013-11-25
How to access Outlook folders, items and fields from Visual Basic?? :-)
0
Comment
Question by:liudan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

801 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