While referencing Return list of names and email address from outlook to vb.net listbox I am trying to fill in a ASP:Textbox with the Office Location of the user.
Currently I pull the current logged in user. The user's username on their PC is also their Outlook Alias. With that being said, I am trying to use the username/Alias to pull the Office location within Outlook. I currently have the following issue with my coding:
'get logged in user(works) Dim username As String Dim User As System.Security.Principal.IPrincipal User = System.Web.HttpContext.Current.User username = User.Identity.Name.Substring(3) 'Office Location of User Dim itemx As String 'Create an Outlook application. Dim oApp As Outlook._Application = New Outlook.Application() 'Get the MAPI namespace. Dim oNS As Outlook.NameSpace = oApp.Session 'Get the Global Address List. Dim oALs As Outlook.AddressLists = oNS.AddressLists Dim oGal As Outlook.AddressList = oALs.Item(1) 'Get all the entries. Dim oEntries As Outlook.AddressEntries = oGal.AddressEntries For Each entry In oEntries If oEntries.GetExchangeUser.Alias = username Then itemx = oEntries.GetExchangeUser.OfficeLocation End If Next