• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Reset Sync Fields

BlueDevilFan has written a fantastic macro:

http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_23992307.html

Which syncs two folders within Outlook, the problem is I've been testing it out and have managed to really mess up the sync fields it uses.

Please is there someone out there (David - are you up for it?) who could write me a macro which cycles through all the records in a folder and resets the various sync fields the above macro uses?

The hope is that then the macro would see the all the records in the source folder as brand new and sync them all over to the target folder, refreshing the messed up sync data.

I've been trying the code below (taken and slightly altered from another ee answer) but it's not working and I don't know if I'm close!

Thanks experts.
Charlie

If one of you could invent a way to email beer I'll gladly buy you a pint or two if you could solve this!
Sub ResetSyncID()
    Dim olkItems As Outlook.Items, _
        olkFolder As Outlook.MAPIFolder, _
        olkItem As Object, _
        olkProperty As Outlook.UserProperty
    Set olkFolder = Application.ActiveExplorer.CurrentFolder
    Set olkItems = olkFolder.Items
    For Each olkItem In olkItems
        'Replace MyPropertyName on the folliwng line with the name of your property
        Set olkProperty = olkItem.UserProperties.Find("SyncID")
        If TypeName(olkProperty) <> "Nothing" Then
            'Replace New Value on the next line with teh new value you want assigned to the property
            olkProperty.Delete
            olkItem.Save
        End If
    Next
    Set olkProperty = Nothing
    Set olkFolder = Nothing
    Set olkItem = Nothing
    Set olkProperty = Nothing
    MsgBox "All done resetting property."
End Sub
 
Sub ResetLastSync()
    Dim olkItems As Outlook.Items, _
        olkFolder As Outlook.MAPIFolder, _
        olkItem As Object, _
        olkProperty As Outlook.UserProperty
    Set olkFolder = Application.ActiveExplorer.CurrentFolder
    Set olkItems = olkFolder.Items
    For Each olkItem In olkItems
        'Replace MyPropertyName on the folliwng line with the name of your property
        Set olkProperty = olkItem.UserProperties.Find("LastSync")
        If TypeName(olkProperty) <> "Nothing" Then
            'Replace New Value on the next line with teh new value you want assigned to the property
            olkProperty.Delete
            olkItem.Save
        End If
    Next
    Set olkProperty = Nothing
    Set olkFolder = Nothing
    Set olkItem = Nothing
    Set olkProperty = Nothing
    MsgBox "All done resetting property."
End Sub

Open in new window

0
RevIngram
Asked:
RevIngram
  • 2
1 Solution
 
RevIngramAuthor Commented:
Hi Experts,
I've managed to sort this myself, can I have the points?
I looked through BlueDevilFan's code, which took several hours as I'm no programmer(!), and maganged to work out what it did. Rather than delete the SyncID or LastSync fields I simply needed to set the LastSync field to "1/1/1900 12:01:00 AM" this makes the macro behave as if the item is new.
I deleted all the items from the target folder, ran the 'ResetLastSync'  mako below on the source folder and we're back in sync.
(BlueDevilFan: if you're reading this I worked out the other problems I was having - mainly due to the fact that I'm syncing in about 4 directions, iPhone, exchange in cached mode, favourite folders and then your macro. I'm now syncng the iPhone via Push instead of iTunes, which gives me multiple contacts folders, enabling me to keep work and home (private and non-private separate). It also removed the need to use cached favourite public folders. By removing 2 of the 4 sync routines it all got alot cleaner)
Cheers,
Charlie
Sub ResetLastSync()
    Dim olkItems As Outlook.Items, _
        olkFolder As Outlook.MAPIFolder, _
        olkItem As Object, _
        olkProperty As Outlook.UserProperty
    Set olkFolder = Application.ActiveExplorer.CurrentFolder
    Set olkItems = olkFolder.Items
    For Each olkItem In olkItems
        'Replace MyPropertyName on the folliwng line with the name of your property
        Set olkProperty = olkItem.UserProperties.Find("LastSync")
        If TypeName(olkProperty) <> "Nothing" Then
            'Replace New Value on the next line with teh new value you want assigned to the property
            olkProperty.Value = "1/1/1900 12:01:00 AM"
            olkItem.Save
        End If
    Next
    Set olkProperty = Nothing
    Set olkFolder = Nothing
    Set olkItem = Nothing
    Set olkProperty = Nothing
    MsgBox "All done resetting property."
End Sub

Open in new window

0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Pending David's appearance to use his knowledge of the solution.  As far as I can see runnu=ing ResetSyncID in the target folder should delete the synch data.  ... mind so will deleting teh old files in entirity ... and remove a potential for duplication.

I may be missing something obvious ... so if you can advise?

Chris
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Oops!

You can ask the admin to delete the question.

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now