Пример #1
0
        private void SynchronizeOutlookAddressBooksImpl()
        {
            _tracer.Trace("Start SynchronizeOutlookAddressBooksImpl");

            IEAddrBook addrBook = OutlookSession.GetAddrBook();

            if (addrBook != null)
            {
                int count = addrBook.GetCount();
                for (int i = 0; i < count; i++)
                {
                    if (ShuttingDown)
                    {
                        return;
                    }
                    OutlookSession.ProcessJobs();
                    IEABContainer abCont = addrBook.OpenAB(i);
                    if (abCont == null)
                    {
                        continue;
                    }
                    using ( abCont )
                    {
                        int displayType = abCont.GetLongProp(MAPIConst.PR_DISPLAY_TYPE);
                        if (displayType != ABType.DT_GLOBAL)
                        {
                            continue;
                        }
                        string entryID = abCont.GetBinProp(MAPIConst.PR_ENTRYID);
                        Core.ResourceAP.RunJob(new OutlookABDescriptor(abCont.GetStringProp(MAPIConst.PR_DISPLAY_NAME), entryID));
                    }
                }
            }
            _tracer.Trace("Start SynchronizeOutlookAddressBooksImpl");
        }
Пример #2
0
 internal static IEMAPIProp OpenMessage(IEFolder folder, IResource contact,
                                        bool create, bool forceCreate, bool trace,
                                        out bool newCreated, out bool createdAsMailUser)
 {
     createdAsMailUser = false;
     newCreated        = false;
     using ( folder )
     {
         IEMAPIProp message = null;
         if (!create)
         {
             string mesEntryId = contact.GetPropText(PROP.EntryID);
             if (mesEntryId.Length > 0)
             {
                 message = OutlookSession.OpenMessage(folder, mesEntryId);
                 if (message == null)
                 {
                     Contact.RemoveFromSync(contact, true);
                 }
             }
             if (!forceCreate)
             {
                 return(message);
             }
         }
         if (message == null)
         {
             string folderId = folder.GetBinProp(MAPIConst.PR_ENTRYID);
             _tracer.Trace(folderId);
             IEAddrBook ab = OutlookSession.GetAddrBook();
             if (ab != null)
             {
                 for (int i = 0; i < ab.GetCount(); ++i)
                 {
                     string abEntryId = ab.FindBinProp(i, MAPIConst.PR_ENTRYID_ASSOCIATED_WITH_AB);
                     if (abEntryId == folderId)
                     {
                         IEABContainer abContainer = ab.OpenAB(i);
                         if (abContainer != null)
                         {
                             using ( abContainer )
                             {
                                 message = abContainer.CreateMailUser( );
                                 if (message != null)
                                 {
                                     createdAsMailUser = true;
                                     return(message);
                                 }
                             }
                         }
                         break;
                     }
                 }
             }
             message    = folder.CreateMessage("IPM.Contact");
             newCreated = true;
         }
         return(message);
     }
 }
Пример #3
0
        [Test] public void OpenAddressBookTest()
        {
            IEAddrBook addrBook = OutlookSession.GetAddrBook();

            Assert.IsNotNull(addrBook);
            int count = addrBook.GetCount();

            for (int i = 0; i < count; ++i)
            {
                IEABContainer ab = addrBook.OpenAB(i);
                Assert.IsNotNull(ab);
                using ( ab )
                {
                }
            }
        }
Пример #4
0
        private void SynchronizeContactsImpl()
        {
            _tracer.Trace("Start SynchronizeContactsImpl");

            Settings.UpdateProgress(0, "Computing Address Books count...", "");
            int totalABs     = Folder.GetFolders(FolderType.Contact).Count;
            int processedABs = 0;

            IEAddrBook addrBook = OutlookSession.GetAddrBook();

            if (addrBook != null)
            {
                int count = addrBook.GetCount();
                totalABs += count;
                for (int i = 0; i < count; ++i)
                {
                    if (ShuttingDown)
                    {
                        return;
                    }
                    OutlookSession.ProcessJobs();
                    ++processedABs;
                    int percentage = (processedABs * 100) / totalABs;
                    Settings.UpdateProgress(percentage, "Synchronizing Address Books", processedABs.ToString());
                    IEABContainer abContainer = addrBook.OpenAB(i);
                    if (abContainer == null)
                    {
                        continue;
                    }
                    using ( abContainer )
                    {
                        ProcessGlobalAddressBook(abContainer);
                    }
                }
            }
            ProcessContactFolders(processedABs, totalABs);
            _tracer.Trace("Finish SynchronizeContactsImpl");

            Settings.UpdateProgress(100, "Synchronizing Address Books", totalABs.ToString());
        }