MackMan
Registered User.
- Local time
- Today, 02:26
- Joined
- Nov 25, 2014
- Messages
- 174
Hi guys. I'm using the following code (with reference to MS Outlook object library) to delete a contact from OL.
However, I'd like to be able to delete using late binding.
Although I'm ok with References to Libraries, Late binding is new to me. I've been having a look around all day yesterday but I'm not sure about :
How I set the contact item (no Jet)
how to set the contacts folder - I've been using const olcontactsfolder = 10 (is this correct?)
I've managed to get late binding to add the contact and it's sorted. But to delete I've been looking for over a day and found nothing to reference to.
is there an easy way to convert early to late? if so how do you guys do it?
As always, help is much appreciated.
Code:
Function DELOUTLOOKCTCT()
On Error GoTo Err_Ctrl
Dim olAppl As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim olCont As Outlook.ContactItem
Dim strContact As String
'****** Set Criteria for DELETION here **
5 strContact = Nz(Me.PayeeName, vbNullString)
'*********************************
10 Set olAppl = Outlook.Application
15 Set objNamespace = olAppl.GetNamespace("MAPI")
20 Set objFolder = objNamespace.GetDefaultFolder(olFolderContacts)
25 For Each olCont In objFolder.Items
30 If olCont.FullName = strContact Then
35 olCont.Delete
End If
Next
40 If Me.txtStatus = "DELETE" Then
45 MsgBox " Contact(s) deleted from Outlook.", vbInformation, "Delete Outlook Contact details..."
End If
Exit_Function:
strContact = vbNullString
Exit Function
Err_Ctrl:
el = Erl
en = Err.Number
ed = Err.Description
errMsgStr = "Del OL Contact Info error."
ctrlfnctnm = "DELOUTLOOKCTCT"
Call form_err(en, ed, ctrlfnctnm, el, errMsgStr)
Resume Exit_Function
End Function
However, I'd like to be able to delete using late binding.
Although I'm ok with References to Libraries, Late binding is new to me. I've been having a look around all day yesterday but I'm not sure about :
How I set the contact item (no Jet)
how to set the contacts folder - I've been using const olcontactsfolder = 10 (is this correct?)
I've managed to get late binding to add the contact and it's sorted. But to delete I've been looking for over a day and found nothing to reference to.
is there an easy way to convert early to late? if so how do you guys do it?
As always, help is much appreciated.