?
Solved

vbscript for coping outlook items cretes duplicate

Posted on 2011-03-11
1
Medium Priority
?
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This video discusses moving either the default database or any database to a new volume.
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
Course of the Month14 days, 10 hours left to enroll

771 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