Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2005, 10:04 AM
Authorized User
 
Join Date: Dec 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mailitem Userproperties

Hello All,

I am trying to retrieve the some user defined fields on an outlook OFT into an excel sheet but i am unable to get the userproperties section to work.
here is the code which i have been using

Sub ListAllItemsInInbox()

   Dim ol As New Outlook.Application
   Dim olns As Outlook.NameSpace
   Dim cf As Outlook.MAPIFolder
   Dim c As Outlook.MailItem
   Dim objItems As Outlook.Items
   Dim Prop As Outlook.UserProperty

    Application.ScreenUpdating = False
    'Workbooks.Add ' create a new workbook
    ' add headings
    Cells(1, 1).Formula = "response"



    With Range("A1:E1").Font
        .Bold = True
        .Size = 14
    End With
    Application.Calculation = xlCalculationManual

   Set olns = ol.GetNamespace("MAPI")
   Set cf = olns.GetDefaultFolder(olFolderInbox)
   Set objItems = cf.Items

   iNumContacts = objItems.Count
   If iNumContacts <> 0 Then
      For i = 1 To 1 'iNumContacts
         If TypeName(objItems(i)) = "MailItem" Then
            Set c = objItems(i)

           Cells(i + 1, 1).Formula = c.UserProperties("resonse")

         End If
      Next i
      MsgBox "Finished."
   Else
      MsgBox "No contacts to export."
   End If

End Sub


when i run it i get the following error:
application-defined or object-defined error

Hope someone can help?







Similar Threads
Thread Thread Starter Forum Replies Last Post
cast DataObject to a MailItem or a PostItem Tiffany Beginning VB 6 1 February 26th, 2004 05:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.