Solved

vbscript for coping outlook items cretes duplicate

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
how to add IIS SMTP to handle application/Scanner relays into office 365.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now