PDA

View Full Version : Solved: Outgoing Messages Folder



ALe
12-07-2005, 01:22 AM
Hello everybody. I'm new at using VBA for Outlook. I'd like to know the best way to identify the folder of th outgoing messages in Outlook.


Thanks

ALe
12-07-2005, 01:42 AM
That's what I found out:
Set myOlApp = CreateObject("Outlook.Application")
Set mynamespace = myOlApp.GetNamespace("MAPI").GetDefaultFolder(4)

Is there any way to know the index and corresponding name of the folders? It must be stupid but I couldn't find it in the guide

ALe
12-07-2005, 01:43 AM
That's what I found out:
Set myOlApp = CreateObject("Outlook.Application")
Set mynamespace = myOlApp.GetNamespace("MAPI").GetDefaultFolder(4)

Is there any way to know the index and corresponding name of the folders? It must be stupid but I couldn't find it in the guide

Killian
12-07-2005, 03:01 AM
OlDefaultFolders constants and their values:

olFolderCalendar 9
olFolderConflicts 19
olFolderContacts 10
olFolderDeletedItems 3
olFolderDrafts 16
olFolderInbox 6
olFolderJournal 11
olFolderJunk 23
olFolderNotes 12
olFolderOutbox 4
olFolderSentMail 5
olFolderTasks 13
olPublicFoldersAllPublicFolders 18

ALe
12-07-2005, 04:45 AM
Very good. Thank you. Where have you found it, please?

Marcster
12-07-2005, 06:12 AM
Ale - You'll find it in the Object Browser. Press F2 while in the VBE.
Then do a search for say, olFolderCalendar.
Or scroll down in the Classes (bottom left) till you see OlDefaultFolders

Killian - Did you write these manually or copy them
from the Object Browser?
Is there any code which could list them, say, in the
Debug.Print window?. :dunno

Marcster.

Killian
12-07-2005, 06:24 AM
What i do to get lists of constant values and other similar stuff is:

copy the constant list from Help (or whenever I can find it)
check in the Object Browser that they're all there
Paste into colB in excel
type "debug.print " in A1 and drag down
type formula "=A1&B1" in C1 and drag down
copy the resulting colC to a routine, run and get the corresponding values from the Immediate window

It seems quite long-winded but it doesn't take to long to get what you need.

ALe
12-12-2005, 03:12 AM
Marcster and Killian - Thank you very much!

Bob Phillips
12-12-2005, 04:17 AM
You might want to try this.

First set a reference to the Typelib dll. You will need to browse for it, it won't be automatically loaded, On my machine it is called TLBINF32.DLL.

Then run this code. It is set for Outlook XP, you might need to check the Outlook OLB file, it might have a version prefix for 2000, or 2003.


Public Sub GetWordConstants()
Dim oOLB As Object
Dim sText As String
Dim oOLBc, oOLBm
Dim j As Integer

On Error Resume Next

With Worksheets("Constants")
With .Range("A1")
.Offset(0, 1).Value = "Outlook"
.Offset(1, 1).Value = "msoutl.olb"
.Cells(3, 1).Resize(.CurrentRegion.Rows.Count, 2).ClearContents
Set oOLB = TypeLibInfoFromFile(Application.path & "\msoutl.olb")
j = 2
For Each oOLBc In oOLB.Constants
For Each oOLBm In oOLBc.Members
.Offset(j, 0).Value = oOLBm.Name
.Offset(j, 1).Value = oOLBm.Value
j = j + 1
Next oOLBm
Next oOLBc
End With
.Visible = True
.Activate
.Range("A1").Select
End With

Set oOLB = Nothing

End Sub


Of course, the Outlook OLB could be substituted by any of the other application OLBs.

Killian
12-12-2005, 12:38 PM
Well I tried it and its a top quality nugget of information - I've got all of the Office constant names and values in 1 workbook now. Handy.
:thumb