Create contact with VBScript

G

Greg Martin

I have the following code to create a contact in a Public Folder. Code was working fine until we upgraded the box it was running on to Win2k. Hasn't run since. I'm not blaming Win2k, just note-ing that the platform did change. Box has Outlook 2000 pre-SR1 installed and CDO.DLL version 5.5.2653.12.

The error is reported on the line with Items.Add (olContactItem) and says:

"Microsoft Outlook: Could not complete the operation. One or more parameter values are not valid"

I have verified the olFoldobj is set correctly by echoing the .name property and got the desired results

Thanks

\\Greg Martin
(e-mail address removed)

Sub AddContact(olFoldobj,Fullname, CompanyName, EMailAddress)
'********************************************
' Adds a contact to the folder object referred to in olFoldObj
'Create and Open a new contact.
Dim olItem 'As Outlook.ContactItem
Const olContactItem = 2
Set olItem = olFoldobj.Items.Add(olContactItem) ' this line generates error

' Set Contact information...
With olItem
.Fullname = Fullname & " (" & CompanyName & ")"
.Email1Address = EMailAddress
.Email1DisplayName = fullname & " (" & CompanyName & ")"
.FileAs = fullname & " (" & CompanyName & ")"
.Email1AddressType = "SMTP"

End With

' Save Contact...
olItem.Save
End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top