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?
|