Managing numerous email accounts (Inbox) through code

I

ID10Terror

Hi:

I am using Outlook 2003 and have a problem. I need to manage about 5
different email accounts (addresses) and I am considering using Outlook to
do that. Let's say I have 5 email accounts (Doe1 thru Doe5). Looking at
"All Mail Folders", each folder is fairly equivilant to "Personal Folders".
I am using Access 2003 to open emails, download into a table, and then move
the email to a sub folder. Because I am using code, I am lost on how to
access each "Inbox" folder through code. As an example, if I want to use
this code to access the folder "Doe2 - Inbox", how do I set this code for
the default folder for that?


Access 2003 Code:
'
Dim Olapp As Outlook.Application
Dim Olmapi As Outlook.NameSpace
Dim Olfolder As Outlook.MAPIFolder
Dim OlAccept As Outlook.MAPIFolder
Dim OlDecline As Outlook.MAPIFolder
Dim OlFailed As Outlook.MAPIFolder
Dim OlMail As Object ' Have to late bind as appointments e.t.c screw it up
Dim OlItems As Outlook.Items
Dim OlRecips As Outlook.Recipients
Dim OlRecip As Outlook.Recipient
Dim Rst As Recordset
'
Set Rst = CurrentDb.OpenRecordset("tblSomething")
Set Olapp = CreateObject("Outlook.Application")
Set Olmapi = Olapp.GetNamespace("MAPI")
Set Olfolder = Olmapi.GetDefaultFolder(olFolderInbox) <---- ???
here, and to what ???
Set OlItems = Olfolder.Items
Set OlAccept = Olfolder.Folders("Passed")
Set OlFailed = Olfolder.Folders("Failed")

Because I have 5 accounts, I have to change the default folder for each one
through code.


TIA
 
S

Sue Mosher [MVP-Outlook]

There is only one default Inbox folder, the one in your default information store.

To get a non-default folder, you need to walk the folder hierarchy starting with the Namespace.Folders collection or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top