I have the following code (bits copied from anywhere!) which seems to work................ BUT....
Appreciate any help
- why is "Const olContactItem = 2" used
- how do I add Notes ? '.Notes = "what a load of rubbish" doesn't work and I just can't find the correct field
- 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