Solved

vbscript for coping outlook items cretes duplicate

Posted on 2011-03-11
1
514 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 500 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Changing a few Outlook Options can help keep you organized!
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…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

688 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