0

Possible Duplicate:
Outlook 2007 VBA to get reference to additional Inbox

Wwe need to open up other users inbox in Microsoft Outlook by File->Open->Other Users's Folder. Then we need to check for a mail. We have tried the below code

  Set olApp=CreateObject("Outlook.Application") 
     Set olns=olApp.GetNameSpace("MAPI") 
     Set objFolder=olns.GetDefaultFolder(6)
     For each item1 in objFolder.Items 
             msgbox item1.subject     
     Next

But with this code we cant able to read mail from other users inbox since the GetDefaultFolder methods Parameter is 6 .. can somebody please help on this

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Prasad
  • 29
  • 2
  • 6

1 Answers1

0

You might want to use something like the following:

Dim objFolder As Outlook.Folder
Set objFolder = Application.Session.PickFolder

This should pop up a box to allow you to choose which folder you are trying to select to read from... However, this option requires some user interaction.

You also may want to try your code with the following change:

Set ObjFolder = Application.Session.GetDefaultFolder(variable)

Where variable is the name of your default folder, ie for your inbox it is olFolderInbox

Steve
  • 88
  • 1
  • 7