Creating Outlook Contacts from Excel

peterhw

New Member
Joined
Jan 23, 2012
Messages
39
I have the following code (bits copied from anywhere!) which seems to work................ BUT....

  1. why is "Const olContactItem = 2" used
  2. how do I add Notes ? '.Notes = "what a load of rubbish" doesn't work and I just can't find the correct field
  3. how do I save to an alternative folder (in this case 'IMS')

Appreciate any help

Code:
Function AddOlContact()Dim olApp As Object
'Dim DestFldr As MAPIFolder
On Error GoTo Error_Handler
    Const olContactItem = 2
    Set olApp = CreateObject("Outlook.Application")
    Set olContact = olApp.CreateItem(olContactItem)
    With olContact
        .FirstName = "FirstName"
        .LastName = "LastName"
        .JobTitle = "no job title"
        .CompanyName = "ACME Trading"
        .Categories = "1_IMS_Work"
        '.Notes = "what a load of rubbish"
        '.Move DestFldr:="IMS" '// moves the contact to the indicated folder
        .Save
        'use .Display if you wish the user to see the contact pop-up
        '.Display
    End With
Error_Handler_Exit:
    On Error Resume Next
    Set olContact = Nothing
    Set olApp = Nothing
    Exit Function
Error_Handler:
    MsgBox "EXCEL has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
    Err.Number & vbCrLf & "Error Source: AddOlContact" & vbCrLf & "Error Description: " & Err.Description, vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
End Function
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top