Results 1 to 6 of 6
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Get UserProperties from Outlook (XP/SP1)

    I have this piece of code that I stole from Helen Federman's site:

    <pre> 'The next line illustrates the syntax for referencing
    'a custom Outlook field
    If itm.UserProperties("Horizons7") <> "" Then
    rnG.Value = itm.UserProperties("Horizons7")
    End If

    If itm.UserProperties("Wetlands") <> "" Then
    rnG.Value = itm.UserProperties("Wetlands")
    End If
    </pre>

    and I figured out what I needed to start retrieving items from Outlook. My problem is that it is only pulling the first <pre>itm.UserProperties</pre>

    and does not write anything for the others.

    Can I get a list of properties and the name that Excel/Outlook uses for them?
    Alan

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Get UserProperties from Outlook (XP/SP1)

    Can you access the properties in the collection like this?

    For Each uProp in itm.UserProperties
    Debug.Print uProp.Name, uProp.Value
    Next

  3. #3
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Get UserProperties from Outlook (XP/SP1)

    Apparently not. That is why it is so frustrating.
    Alan

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Get UserProperties from Outlook (XP/SP1)

    Try it with:

    For i = 1 To itm.UserProperties.Count
    Select Case itm.UserProperties(i).Name
    Case "Horizons7"
    myvariable = itm.UserProperties(i).Value
    ...
    Next i

    Sorry, have only one single UserProperty in Contacts so test against. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Get UserProperties from Outlook (XP/SP1)

    Fantastic! <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35> You gave me enough that I was able to add this to my code and get the names I need:

    <pre> For G = 1 To itm.UserProperties.Count
    ThisWorkbook.Sheets("Sheet3").Cells(G, 1) = itm.UserProperties(G).Name
    Next G </pre>

    Alan

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Get UserProperties from Outlook (XP/SP1)

    It's an odd thing. Jefferson's approach using

    for each object in collection

    should work, but I frequently have problems with it, so I usually use

    for i = 1 to collection.items.count

    when operating on collections.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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