Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Notes From MS Outlook 1

Status
Not open for further replies.

PBAPaul

Programmer
Aug 3, 2002
140
0
0
GB
I have a VBA program that opens my Contacts folder so that I can manipulate the data contained in it.

My problem is that I can get all the information I need, Title, FirstName,BusinessAddress etc but I cannot find any reference to "Notes". This is the large memo area at the bottom of the General tab of each Contact.

I cannot find the field using the "All Fields" tab of each Contact nor can I find any reference in the Object Browser in Excel.

Yet when you do a manual import or export from MS Outlook then there is the field "Notes"!

Can anyone please tell me the reference to the field. I am using XP Pro and Office XP Pro and I use the technique below, in Excel, to get my data.
Code:
    Dim objContactsFolder As Outlook.MAPIFolder
    Dim objContacts As Outlook.Items
    Dim objContact As Object
    Dim iCount As Integer

    Set objContactsFolder = Session.GetDefaultFolder(olFolderContacts)
    Set objContacts = objContactsFolder.Items
    iCount = 0

    For Each objContact In objContacts
        If TypeName(objContact) = "ContactItem" Then
            ClearVariables
            With oDB
                DataLine(1) = objContact.Categories
                DataLine(2) = objContact.Title
                Etc .....

Thanks for any help.
 
Hi PBAPaul,

I have just found this:
Note: When programmatically referring to the Message field, is is referred to as the Body property.

"is is" > "it is" (Their mistake not mine!)

Half way down this article:

I have checked in the object browser and there is a Body Property for the ContactItem Object. I have not checked that it works in any code yet, but I think this is what you are looking for.
Let me know how it goes,
Matt
 
Hi Matt

Thanks for the input but .....

I added a contact in MS Outlook as "Mr A Sample" and a note of "This is a test".

If I manually export it into Excel then there is the Note of "This is a test"!

I have tried the Body property for the ContactItem property but with no joy. I have searched through the object browser and there seems to be nothing applicable.

Any other ideas?
 
Hi PBA Paul,

I tried the following code:

Code:
Sub GetNotesFromOutlook()
    Dim objContactsFolder As Outlook.MAPIFolder
    Dim objContacts As Outlook.Items
    Dim objContact As Object
    Dim iCount As Integer
    Dim objProperty As Outlook.ItemProperty
    
    Set objContactsFolder = Session.GetDefaultFolder(olFolderContacts)
    Set objContacts = objContactsFolder.Items
    iCount = 0

    For Each objContact In objContacts
        If TypeName(objContact) = "ContactItem" Then
                Debug.Print objContact.FileAs & " : " & objContact.Body
        End If
    Next
End Sub

and got the following in the immediate window:
Sample, A : This is the notes field
Sample, B : These are the notes for Mr. B Sample

Are we refering to the same field?
I have tested the code with Outlook XP and 2003, and it seems to work on both, which version of Outlook are you using?

Hope this helps
 
Hi Matt

Thanks for the code.

I don't know what I did, but when I originally tried "Body" then I did not get anything.

I have tried again using objContact.Body and I pull down the Notes as intended.

My many thanks for your help.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top