Consulting

Results 1 to 10 of 10

Thread: Solved: Outgoing Messages Folder

  1. #1
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location

    Solved: Outgoing Messages Folder

    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

  2. #2
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    That's what I found out:
    [VBA] Set myOlApp = CreateObject("Outlook.Application")
    Set mynamespace = myOlApp.GetNamespace("MAPI").GetDefaultFolder(4) [/VBA]

    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

  3. #3
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    That's what I found out:
    [VBA] Set myOlApp = CreateObject("Outlook.Application")
    Set mynamespace = myOlApp.GetNamespace("MAPI").GetDefaultFolder(4) [/VBA]

    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

  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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
    K :-)

  5. #5
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    Very good. Thank you. Where have you found it, please?

  6. #6
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location
    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?.

    Marcster.

  7. #7
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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.
    K :-)

  8. #8
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    Marcster and Killian - Thank you very much!

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.

    [vba]
    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
    [/vba]

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

  10. #10
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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.
    K :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •