Outlook Operation Fails when trying to access the Exchange GlobalAddress List

F

Fred Ferguson

My organization recently upgraded our Exchange server from Exchange 2003 to 2010. Since the upgrade some users are experiencing issues connecting to the new exchange server Global Address list from a custom VB.NET windows application using the Microsoft.Office.Interop.Outlook 12.0 Libraray. The Application was developed with VS 2008 and deployed via ClickOnce with Prerequisite Office Runtime 3.0 SP1. When the applicatoin attempts to access the exchange global address list, a pop-up message from outlook displays: "Outlook is trying to retrieve data from Myserver.Domain", and shortly after the app give an exception "Outlook Operation Failed". All users are on Outlook 2007. Below is the VB code used. I'm not sure if the issue is with the code, version of the Interop Library, or a setting on the users computer or exchange server. (Outlook Trust Center setting are all set properly)

PLEASE HELP! pretty stuck at this point.

VB Code.
----------------------------------
Dim olA As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application
Dim Ns As Microsoft.Office.Interop.Outlook.NameSpace = olA.GetNamespace("MAPI")
Dim AddressEntry As Microsoft.Office.Interop.Outlook.AddressEntry = Nothing
Dim olAddressList As Microsoft.Office.Interop.Outlook.AddressList = Ns.GetGlobalAddressList
Dim objExuser As Microsoft.Office.Interop.Outlook.ExchangeUser = Nothing
Dim Address As String = ""
Dim strName As String = ""

Dim AddressArray() As String = Nothing
m_strProc = "ModCombos.ExchangeEmail"

Try
m_dt = New DataTable
m_dt.Columns.Add("ExUser_Name", GetType(String))
m_dt.Columns.Add("Smtp_Address", GetType(String))

For Each Entry In olAddressList.AddressEntries
Dim objExGroup As Microsoft.Office.Interop.Outlook.ExchangeDistributionList = Nothing
objExuser = Nothing
AddressEntry = Entry
strName = AddressEntry.Name
objExuser = AddressEntry.GetExchangeUser

If objExuser Is Nothing Then objExGroup = AddressEntry.GetExchangeDistributionList

If Not objExuser Is Nothing Then
Address = objExuser.PrimarySmtpAddress.ToString
m_dt.Rows.Add(strName, LCase(Address))
ElseIf Not objExGroup Is Nothing Then
Address = objExGroup.PrimarySmtpAddress.ToString
m_dt.Rows.Add(strName, LCase(Address))
ElseIf AddressEntry.Address.Contains("/") Then
AddressArray = Split(AddressEntry.Address, "/")
Address = AddressArray(4).ToString
Address = LCase(Mid(Address, InStr(Address, "=") + 1, Len(Address)))
If Not UCase(Right(Address, 7)) = "MyCompany.ORG" Then Address = Address & "@Mycompany.org"
m_dt.Rows.Add(strName, Trim(Address))
ElseIf UCase(Right(AddressEntry.Address, 7)) = "MyCompany.ORG" Then
Address = Trim(AddressEntry.Address)
m_dt.Rows.Add(strName, LCase(Address))
End If
Next

ExchangeDt = m_dt


m_dt = Nothing
olA = Nothing
Ns = Nothing
olAddressList = Nothing
objExuser = Nothing
AddressEntry = Nothing

Return ExchangeDt


Catch ex As Exception
MsgBox(ex.Source & vbCrLf & ex.Message, MsgBoxStyle.Critical, "ERROR: " & m_strProc)
Err.Clear()

m_dt = Nothing
olA = Nothing
Ns = Nothing
olAddressList = Nothing
objExuser = Nothing
AddressEntry = Nothing

Return Nothing

End Try

End Function
 
F

Fred Ferguson

Thanks for your post Marshal. I will check it out and let you know if it worked or not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top