INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA Monitor Non-Default folder in Outlook

VBA Monitor Non-Default folder in Outlook

(OP)
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


RE: VBA Monitor Non-Default folder in Outlook

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

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("your account name")
Set oStore = oAccount.DeliveryStore
Set oFolder = oStore.GetDefaultFolder(olFolderInbox) 

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

For Each oAccount In oNameSpace.Accounts
    ' identify the account some way ..
    ' perhaps from oAccount.SmtpAddress or oAccount.UserName
Next 

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close