コード例 #1
0
ファイル: apioutlook.cs プロジェクト: xlgwr/hr
 public void GetCurrentUserMembership(DataGridView dgv)
 {
     Outlook.AddressEntry currentUser =
         app.Session.CurrentUser.AddressEntry;
     if (currentUser.Type == "EX")
     {
         Outlook.ExchangeUser exchUser =
             currentUser.GetExchangeUser();
         if (exchUser != null)
         {
             Outlook.AddressEntries addrEntries =
                 exchUser.GetMemberOfList();
             if (addrEntries != null)
             {
                 foreach (Outlook.AddressEntry addrEntry
                          in addrEntries)
                 {
                     DataGridViewRow dgvr = new DataGridViewRow();
                     dgvr.CreateCells(dgv);
                     dgvr.Cells[0].Value = addrEntry.Name;
                     dgvr.Cells[1].Value = addrEntry.Address;
                     dgv.Rows.Add(dgvr);
                 }
             }
         }
     }
 }
コード例 #2
0
 public string[] getAddresses(int index)
 {
     string[] addressesArr = null; // 保存邮件组下的成员地址
     if (this.addressList[index] is Outlook.DistListItem)
     {
         Outlook.DistListItem distListItem = (Outlook.DistListItem) this.addressList[index];
         addressesArr = new string[distListItem.MemberCount];
         for (int i = 0; i < distListItem.MemberCount; i++)
         {
             Outlook.Recipient recipient = distListItem.GetMember(i + 1);
             addressesArr[i] = recipient.Name + " " + recipient.Address;
         }
     }
     else if (this.addressList[index] is Outlook.AddressEntries)
     {
         Outlook.AddressEntries addresses = (Outlook.AddressEntries) this.addressList[index];
         addressesArr = new string[addresses.Count];
         for (int i = 1; i <= addresses.Count; i++)
         {
             Outlook.AddressEntry membAddress = addresses[i];
             addressesArr[i - 1] = membAddress.Name + " " + membAddress.GetExchangeUser().PrimarySmtpAddress;
         }
     }
     return(addressesArr);
 }
コード例 #3
0
ファイル: apioutlook.cs プロジェクト: xlgwr/hr
 public void GetDistributionListMembers(string addlistname, DataGridView dgv)
 {
     Outlook.SelectNamesDialog snd =
         app.Session.GetSelectNamesDialog();
     Outlook.AddressLists addrLists =
         app.Session.AddressLists;
     foreach (Outlook.AddressList addrList in addrLists)
     {
         if (addrList.Name == addlistname)
         {
             snd.InitialAddressList = addrList;
             break;
         }
     }
     snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo;
     snd.ToLabel = "D/L";
     snd.ShowOnlyInitialAddressList = true;
     snd.AllowMultipleSelection     = false;
     snd.Display();
     if (snd.Recipients.Count > 0)
     {
         Outlook.AddressEntry addrEntry =
             snd.Recipients[1].AddressEntry;
         if (addrEntry.AddressEntryUserType ==
             Outlook.OlAddressEntryUserType.
             olExchangeDistributionListAddressEntry)
         {
             Outlook.ExchangeDistributionList exchDL =
                 addrEntry.GetExchangeDistributionList();
             Outlook.AddressEntries addrEntries =
                 exchDL.GetExchangeDistributionListMembers();
             if (addrEntries != null)
             {
                 foreach (Outlook.AddressEntry exchDLMember
                          in addrEntries)
                 {
                     DataGridViewRow dgvr = new DataGridViewRow();
                     dgvr.CreateCells(dgv);
                     dgvr.Cells[0].Value = exchDLMember.Name;
                     dgvr.Cells[1].Value = exchDLMember.Address;
                     dgv.Rows.Add(dgvr);
                     // Debug.WriteLine(exchDLMember.Name);
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: EmailManager.cs プロジェクト: punker76/Builder
        private void LoadContactsList()
        {
            Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();

            Outlook.Folder contactsFolder = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders) as Outlook.Folder;

            Outlook.Folder currentFolder = outlookApp.ActiveExplorer().CurrentFolder as Outlook.Folder;
            Outlook.Store  currentStore  = currentFolder.Store;

            Outlook.AddressList    addressList = this.GetGlobalAddressList(outlookApp, currentStore);
            Outlook.AddressEntries entries     = addressList.AddressEntries;

            this._contactsList = new List <Contact>();

            foreach (Outlook.AddressEntry entry in entries)
            {
                Outlook.ExchangeDistributionList distList = entry.GetExchangeDistributionList();
                Outlook.ExchangeUser             user     = entry.GetExchangeUser();
                Outlook.ContactItem contact = entry.GetContact();

                if (distList != null)
                {
                    this._contactsList.Add(new Contact(distList.Name, distList.PrimarySmtpAddress));
                }

                if (contact != null)
                {
                    this._contactsList.Add(new Contact(contact.FirstName + " " + contact.LastName, contact.IMAddress));
                }

                if (user != null)
                {
                    if (user.FirstName == null && user.LastName == null)
                    {
                        this._contactsList.Add(new Contact(user.Name, user.PrimarySmtpAddress));
                    }
                    else
                    {
                        this._contactsList.Add(new Contact(user.FirstName + " " + user.LastName, user.PrimarySmtpAddress));
                    }
                }
            }
        }
コード例 #5
0
        private void EnumerateDL(Outlook.AddressEntry dl, string prefix = "")
        {
            if (AlreadyEnumeratedDL(dl))
            {
                System.Diagnostics.Debug.WriteLine(prefix + dl.Name + "> <skipping nested dl>");
            }
            else
            {
                _seenDLs.Add(dl);

                Outlook.ExchangeDistributionList exchDL      = dl.GetExchangeDistributionList();
                Outlook.AddressEntries           addrEntries = exchDL.GetExchangeDistributionListMembers();

                if (addrEntries != null)
                {
                    foreach (Outlook.AddressEntry exchDLMember in addrEntries)
                    {
                        if (exchDLMember.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeDistributionListAddressEntry)
                        {
                            EnumerateDL(exchDLMember, prefix + dl.Name + " > ");
                        }
                        else
                        {
                            var entry = prefix + dl.Name + " > " + exchDLMember.Name;
                            System.Diagnostics.Debug.WriteLine(entry);
                            lstMembers.Items.Add(entry);

                            if (exchDLMember.Address == _currentUser.Address)
                            {
                                MessageBox.Show("Found You!\n\n" + entry);
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
 public void addAddressNativeGroupList(Outlook.ExchangeDistributionList disList) // 普通组邮件成员list添加到addressList区存储
 {
     Outlook.AddressEntries addressEntries = disList.GetExchangeDistributionListMembers();
     this.addressList.Add(addressEntries);
 }