?
Solved

vbscript for coping outlook items cretes duplicate

Posted on 2011-03-11
1
Medium Priority
?
524 Views
Last Modified: 2012-06-27
I have the following script that copies outlook contact items from a folder to another folder. The problem is that if the contact already exists, it creates duplicates. Is there any way to address this issue?


#########################################################################
Const olFoldercontacts = 10

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set objcontacts = objNamespace.GetDefaultFolder(olFoldercontacts)
strFolderName = objcontacts.Parent
Set objMailbox = objNamespace.Folders(strFolderName)

Set myFolder = objNamespace.Folders("Mailbox - Test2")
Set objFolder = myfolder.Folders("Contacts")

Set colItems = objcontacts.Items
For each objItem in colItems
 If objitem.LastModificationTime > DateAdd("d", -10, Now()) then
      Set objCopy = objItem.Copy  
      objCopy.move objFolder
end if
next
0
Comment
Question by:kkrit
1 Comment
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 2000 total points
ID: 35117678
First search for that contact in the target folder by FullName, and don't copy if it is found.  This is not perfect, since the name may be entered slightly differently, and also it doesn't allow updating of just the new information.  Outlook is much less flexible than Access.  In my latest book I write code to do two-way synchronzing of contact data between Outlook and Access, but this is very complicated, if you need to cover all possibilities.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
Take a look at these 6 Outlook Email management tools which can augment the working and performance of Microsoft Outlook to give you a more rewarding emailing experience.
This video discusses moving either the default database or any database to a new volume.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 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