Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Monitor Non-Default folder in Outlook

Status
Not open for further replies.

scriverb

Programmer
May 17, 2002
4,485
0
0
US
I want to monitor a secondary Outlook account from ACCESS. I have a user with a second account that is being monitored in Outlook. If I change the Default account so that 2nd account is the Default I can perform all the actions necessary but I can't have it be the default account as they need their individual account to be the default.
How do I Set the olFolder to the 2nd account rather than the Personal default account as you can see in the code below?

Set olFolder = Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)

I am linked to the correct folders and can process the data from the folders but after all the database stuff is finished I need to Save the Attachment to a specific folder and then move the email to a completed folder.

It has been a long time since I have been on this site. Way back when I was very active. But, still active ACCESS programmer. Thought you guys could help here.

Thanks

Bob


Bob Scriver
MSU Spartan


 
Hi Bob,

I only visit occasionally now but recognise your name from way back.

What you want is the default folder for an account rather than the default for the namespace, which you should be able to get via the account, if you know the name of the account ..

Code:
[blue]Dim oOutlook        As Outlook.Application
Dim oNameSpace      As Outlook.NameSpace
Dim oAccount        As Outlook.Account
Dim oStore          As Outlook.Store
Dim oFolder         As Outlook.Folder

Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNamespace("MAPI")
Set oAccount = oNameSpace.Accounts("[i][COLOR=#A40000]your account name[/color][/i]")
Set oStore = oAccount.DeliveryStore
Set oFolder = oStore.GetDefaultFolder(olFolderInbox)[/blue]

If you don't know the name of the account, you'll need to be able to identify it somehow by stepping through them ..

Code:
[blue]For Each oAccount In oNameSpace.Accounts
    [green]' identify the account some way ..
    ' perhaps from oAccount.SmtpAddress or oAccount.UserName[/green]
Next[/blue]

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top