Create contact with VBScript

G

Greg Martin

I have the following vbscript 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.
'olFoldobj must be an outlook object pointing to the folder

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
 
S

Sue Mosher [MVP]

I don't know why a change of server o/s would make a difference, but if olFoldobj is a contacts folder, the olContactItem argument is unnecessary.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
G

Greg Martin

Sue, the folder is a Public Folder with default type sent to contact. If I
take out the olContactItem argument, the add.items call is successful, but I
then get an error on this line:

..Email1DisplayName = fullname & " (" & CompanyName & ")"

saying "Microsoft Outlook: Property is read-only"

Any thoughts on that?

(Again, this script has been running for a year and I really, really didn't
change anything!)

\\Greg


I don't know why a change of server o/s would make a difference, but if
olFoldobj is a contacts folder, the olContactItem argument is unnecessary.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 

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