locked
Outlook .pst folders synch using microsoft framevork for c# RRS feed

  • Question

  • Im trying to synchronize folders in outlook pst file using microsoft synch framework. Now I have done synchronization of simple folders and files, but when it comes down to outlook pst file folders, Im kinda lost. so this is what i have got:

            List<MailItem> mailItems = new List<MailItem>();
            Application app = new Application();
            NameSpace outlookNs = app.GetNamespace("MAPI");
            outlookNs.AddStore(@"C:\Test.pst");
            MAPIFolder rootFolder = outlookNs.Stores["Test"].GetRootFolder();
            Folders subFolders = rootFolder.Folders;
    
            //the fun part
            String folderPathForSynchA;
            String folderPathForSynchB;
            //subFolders[1].FolderPath is "deleted items" which doesn't even exist in my outlook 
            //subFolders[2&3].FolderPaths contain the desired email folder paths for sych
            // we get path for the first
            folderPathForSynchA = @"C:\Test.pst"+subFolders[2].FolderPath;
            folderPathForSynchB = @"C:\Test.pst"+subFolders[3].FolderPath;      
    
    
            FileSyncProvider providerA = new FileSyncProvider(Guid.NewGuid(),folderPathForSynchA); 
            // exeption "Could not find a part of the path 'C:\Test.pst\\Test\Inbox"
            // I'm guessing I should somehow assign a list of objects here...
            FileSyncProvider providerB = new FileSyncProvider(Guid.NewGuid(), folderPathForSynchB);
    
             providerA.DetectChanges();
             providerB.DetectChanges();
    
             SyncOrchestrator agent = new SyncOrchestrator();
             agent.LocalProvider = providerA;
             agent.RemoteProvider = providerB;
             agent.Direction = SyncDirectionOrder.UploadAndDownload;
             agent.Synchronize();

    So how should I change this? Maybe you know any good tutorials?

    I found this Contact Synchronization Sample (C#) but still can't find the example in msdn

    Monday, August 13, 2012 9:07 PM

All replies

  • the filesyncprovider is for synching files, not synching specific contents of files.

    outlook folders are different from file sytem folders.

    you will have to build your own sync provider for outlook.

    Tuesday, August 14, 2012 2:24 AM
  • Ok , now how does one build a specific sync provider? tutorial link perhaps :) ?

    Tuesday, August 14, 2012 5:53 AM
  • the documentation that comes and gets installed with the framework is a good start.

    its not for the faint of heart though.

    Tuesday, August 14, 2012 10:35 AM
  • It is not because things are difficult that we do not dare, it is because we do not dare that things are difficult.


    • Edited by 5745556 Tuesday, August 14, 2012 7:07 PM
    Tuesday, August 14, 2012 4:36 PM
  • dude you're like the only one who knows this stuff, so could you try to help a bit more??
    Monday, August 20, 2012 4:53 PM