|
-
Jul 23rd, 2008, 04:52 PM
#1
Thread Starter
New Member
Delete Contacts VB Script
Hello,
Please allow me to preface this by stating that I am not a programmer. That being said, I am working on a script that will import all contacts from a public contacts folder in exchange to a contacts folder in a mailbox. I found a script for the import portion, but it doesn't check for duplicates. So I either need to delete all existing contacts first, or find a way to check for duplicates in the existing script. Either would work. I managed to piece together a script for deleting all contacts first, but it only deletes half of the existing contacts. I'm sure it's a syntax problem somewhere. Any help would be greatly appreciated.
Here is the delete script:
servername = "servername"
mailbox = "mailboxname"
set objSession = CreateObject("MAPI.Session")
strProfile = servername & vbLf & mailbox
objSession.Logon "",,, False,, True, strProfile
Set objcontactfolder = objSession.getdefaultfolder(5)
for each objcontact in objcontactfolder.messages
wscript.echo objcontact
objcontact.delete
set objcontact = nothing
next
objsession.Logoff
Here is the import script
servername = "servername"
mailbox = "mailbox name"
pubContactsfolderid = "000000001A447390AA6611CD9BC800AA002FC45A03002BC1B9FAA75074498734ECF3045FA952000000004E410000"
set objSession = CreateObject("MAPI.Session")
strProfile = servername & vbLf & mailbox
objSession.Logon "",,, False,, True, strProfile
Set objcontactfolder = objSession.getdefaultfolder(5)
Set collAddressLists = objSession.AddressLists
Set objInfoStore = objSession.GetInfoStore(objSession.Inbox.StoreID)
Set objpubstore = objSession.InfoStores("Public Folders")
set objpubContactsfolder = objSession.getfolder(pubContactsfolderid,objpubstore.id)
Set collAddressLists = objSession.AddressLists
for each objcontact in objpubContactsfolder.messages
set objCopyContact = objcontact.copyto(objcontactfolder.ID,objInfoStore.ID)
objCopyContact.Unread = false
objCopyContact.Update
Set objCopyContact = Nothing
wscript.echo objcontact.subject
next
objsession.Logoff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|