2017-05-31 3 views
0

Ich habe den unten stehenden Code und derzeit mein Outlook-Profil hat 2 Konten. 1. Mine (individuell) 2. Firmenverteilerliste und ich habe den Code untenOutlook addin-Konten Schleife

Outlook.Accounts accounts = OutlookApp.Session.Accounts; 
     foreach (var acc in accounts) 
     { 
      var myNameSpace = OutlookApp.GetNamespace("MAPI"); 

      var myAddressList = myNameSpace.GetGlobalAddressList(); 

      Debug.Write(myAddressList.AddressEntries.Count); 
      foreach (Outlook.AddressEntry addressEntry in myAddressList.AddressEntries) 
      { 
       // Debug.Write(addressEntry.Name); 
      } 

Ich möchte nach der individuellen Adressliste von Konten bestellen. Wie bestellen wir OutlookApp.Session.Accounts?

Danke,

Antwort

0

die LINQ OrderBy-Methode verwenden:

Outlook.Accounts accounts = OutlookApp.Session.Accounts; 
foreach (var acc in accounts.OfType<Outlook.Account>().OrderBy(a => a.DisplayName)) 
{ 
    var myNameSpace = OutlookApp.GetNamespace("MAPI"); 
} 
0

Verwenden Namespace.Stores Sammlung speichert in Ihrem Profil zuzugreifen.