Solved

vbscript for coping outlook items cretes duplicate

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

Make managing Office 365 email signatures a breeze

Are you using Office 365? Having trouble trying to set up email signatures for your users? Getting stressed out managing multiple signatures? Need an easier way to manage? We have a solution for you, try the most-user friendly and powerful signature management tool on the market.

Question has a verified solution.

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Read this checklist to learn more about the 15 things you should never include in an email signature.
To show how to create a transport rule 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 >> Rules tab.:  To cr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

937 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

4 Experts available now in Live!

Get 1:1 Help Now