public void dgvaddEmailUsernameByExchange(object o) { var exchange = ns.GetGlobalAddressList(); foreach (Outlook.AddressEntry item in exchange.AddressEntries) { Outlook.ExchangeUser exuser = item.GetExchangeUser(); Program._exuser.Add(exuser); } Program._exuserThreadinitover = true; }
private static void GetGlobalAddress(Microsoft.Office.Interop.Outlook.NameSpace ns) { Console.WriteLine("[*] Try to get global address"); Console.WriteLine(); Console.WriteLine("[!] Notice:When the antivirus software is inactive or out-of-date,it will pop up a Outlook security prompt.\r\n"); AddressList aL = ns.GetGlobalAddressList(); AddressEntries aEs = aL.AddressEntries; for (int i = 0; i < aEs.Count; i++) { Console.WriteLine(aEs[i + 1].GetExchangeUser().PrimarySmtpAddress); } }
private Outlook.ExchangeUser SearchExchange(string name, Outlook.NameSpace _ns = null) { if (Globals.ThisAddIn.Offline) { return(null); } Outlook.NameSpace ns = _ns; if (ns == null) { ns = Globals.ThisAddIn.Application.GetNamespace("MAPI"); } if (ns != null) { var addresslist = ns.GetGlobalAddressList(); if (addresslist != null) { try { var addressItem = addresslist.AddressEntries[name]; if (addressItem != null && ( addressItem.AddressEntryUserType == Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry || addressItem.AddressEntryUserType == Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)) { return(addressItem.GetExchangeUser()); } } catch (System.Runtime.InteropServices.COMException) { return(null); } } } return(null); }