Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


A Script to Copy Contacts Within Outlook?

Posted on 2003-03-14
Medium Priority
Last Modified: 2007-12-19
Within our company, we keep a main contact book in outlook's public folders for all of our employees to access and several of our guys have palms/cell phones that synch with outlook. In order to synch, they copy all of the contacts over from the main address book into their personal contacts folder and synch with that.  We have had a problem several times with some of our not-so-computer-savvy users...rather than COPYING from the primary contact folder into their own, they are cutting and pasting..which obviously can mess up quite a few things for a lot of other people.  I am trying to find out how to write, or find an existing script that will copy the contacts from one contact folder to another for them so we can avoid this problem altogether. I created a script previously that copies some of our finance files over to the server for backup automatically but I'm not familiar with the internal workings of the outlook files..etc..

Can anyone point me in the right direction??

Jamie K.
Question by:jamie_k

Accepted Solution

rjcpjc earned 152 total points
ID: 8141255
You would need to work with the Outlook object model to get at that data. What version of Outlook? If Outlook 2000 or 2002 you can use VBA do this.

Assisted Solution

mesch earned 148 total points
ID: 8146039
Hey Jamie

this sample demonstrates how to copy ContactItems from the public folder (Public Folder/All Public Folders/Global Contacts)to a users default contact folder. I wrote that in a simple Outlook form, which can be accessed through the action menu of the Global Contacts folder:

Option Explicit

Const olFolderContacts = 10

Sub CommandButton1_Click()

Dim scrFolder, desFolder, oNS, oContactItem, otmpContactItem

Set oNS = Application.GetNameSpace("MAPI")
'-- set source folder object
Set scrFolder = oNS.Folders("Public Folders").Folders("All Public Folders").Folders("Global Contacts")
'-- set destination folder object (default contact folder of users mailbox)
Set desFolder = oNS.GetDefaultFolder(olFolderContacts)
'Copy all ContactItems from source to destination folder
For Each oContactItem In scrFolder.Items
  Set otmpContactItem = oContactItem.Copy
  otmpContactItem.Move desFolder
  Set otmpContactItem = Nothing

'-- clean up memory
Set desFolder = Nothing
Set scrFolder = Nothing
Set oNS = Nothing
End Sub


Expert Comment

ID: 13283456

I am looking for something exactly along the lines of what your sample script addresses - but I am new to forms.  Can you please share some additional info on how to attach this script to a form and run it?  I can create a form and publish it...



Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
A few solutions to a problem some of us have been having when trying to add Hostgator email accounts to Outlook 2016 (will probably work with Outlook 2013 as well).
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question