access different folder

G

Guest

Hi,

I already know excel VBA but I am trying to programmically access Outlook
from Excel. I have a few questions:

i managed to access my main inbox that on this location:

personal folders > Inbox

how do i access in VBA another folder that's on the same level as "personal
folders". for example, the archive folders or another main folder i created
on that level.

do give you an idea what i mean, this would be the xml-style structure:

<personal folders>
<folder x>
<inbox >
</personal folders>

<main folder >
<folder i would like to access>
<folder 1>
</main folder>


- how do i send email from another account than the standard email account?

on www.outlookcode.com i found a book that might help me. Is it usefull? I
use office 2003 so i would rather have a book on outlook 2003 vba
exclusively. Is there such a book or is the book on outlookcode (2002
version) the onlye available book?

kind regards,

Tamar
 
G

Guest

Every .pst or top-level store in Outlook is also an entry in the top-level
folders collection that you can retrieve from NameSpace.Folders. So to get
your "Personal Folders" store, you'd call:

Dim objNS As Namespace
Dim objMyFolders As Folders
Dim objMyTopLevelFolder As MAPIFolder

Set objNS = Application.GetNamespace("MAPI")
Set objMyFolders = objNS.Folders("Personal Folders")
Set objMyTopLevelFolder = objMyFolders("Inbox")

As for choosing the e-mail account to send the message with, there is no
point checking to see if an account hasn't been chosen because the default
account is always used if no other account is selected. The only way to
programmatically set the sending account is to get a reference to the menu
item and call it's Execute method (however, you need to know the name or
ordinal position of the account name in the menu):

Sub ChangeSendingAccount()
Dim objCBPU As Office.CommandBarPopup
Dim objCBB As Office.CommandBarButton

Set objCBPU = ActiveInspector.CommandBars.FindControl(, 31224) 'get
Accounts button on Standard toolbar

'Get menu item by name or index number
Set objCBB = objCBPU.Controls.Item("&1 Microsoft Exchange Server")
'Set objCBB = objCBPU.Controls.Item(2)

objCBB.Execute

Set objCBPU = Nothing
Set objCBB = Nothing
End Sub

And yes, that book on Outlookcode.com is the best for you, and is applicable
for programming with Outlook 2000-2003.
 

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