none
Outlook Operation Fails with Office.Interop.Outlook RRS feed

  • Question

  • My organization recently upgraded our exchange server from Exchange 2003 to Exchange 2010. All of our users are using Outlook 2007. 

    I have a VB.Net Windows application which uses Microsoft.Office.Interop.Outlook for Outlook 2007. After the upgrade and migration to the new exchange server users are now experiencing errors when trying to access the Exchange Global Address list. My application loads a DataTable with the with address enties on starup. Some users are now experiencing and pop-up message from Outlook saying: "Outlook is tying to retrieve data from MyExchangeServer.Domain and then the exceptoin from the application: "Micosoft Outlook Operation Failed" The strange thing is that is not occurring for everyone and according to our Server Admin, there is nothing that they are aware of that is limiting the number of user connections to the server.

    My Application is developed using VS 2008, compiled for Tagert CPU x86, .Net Framework 3.5.  Is is deplyoed with ClickOnce with Prerequisties: VS Tools for the office syste, 3.0 Runtime Service Pack 1. Code Below:

    Please, Please Help!

    Public Function ExchangeDt() As DataTable

            'Loading the exchange Address book into Data Table.

            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)) = "CHP.ORG" Then Address = Address & "@chp.org"
                        m_dt.Rows.Add(strName, Trim(Address))
                    ElseIf UCase(Right(AddressEntry.Address, 7)) = "CHP.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

     


    VB.Net Dev

    Monday, May 7, 2012 6:12 PM

All replies

  • Hi FredFeruguson,

    Thanks for posting in the MSDN Forum.

    I would recommend you get mail address via PrimarySmtpAddress property. Let's see whether it can fix your issue.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 8, 2012 8:38 AM
    Moderator
  • Thank you for response Tom,

    In the code from my original post, I am using the PrimarySmtpAddress property to get the email address. I am only using the parsing string method from the AddressEntry.Address property if there is a custom entry where no PrimarySmtpAddress is present (See Blow)

     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))

     This code has worked fine before the upgrade of the exchange server and it works fine for most users. I am truly stuck..


    VB.Net Dev

    Tuesday, May 8, 2012 2:09 PM
  • Hi FredFeruguson,

    OK, I will involve some experts into your issue to see whether they can help you out. There might be some time delay, thanks for you patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 10, 2012 5:57 AM
    Moderator
  • Hi Fred,

    When you say that it's not working for just some users, is it consistently failing for these users, or is it a sporadic problem?

    For the problem users, is Outlook in cached or online mode? Is the Offline Address Book configured for these users?


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Thursday, May 10, 2012 7:21 PM
    Moderator
  • Hello Bill,

    Thank you for your  repsponse.

    The application is consistanly failing for some users and sporadically for a few.  All of the users should be in cached mode with offline Address Book configured. I will confirm this with our PC support staff and let you know promptly.

    Thanks Again.


    VB.Net Dev

    Thursday, May 10, 2012 7:48 PM
  • Fred, would it be possible for you to open a support incident for this? Assuming you have a user who can reproduce this consistently, I suspect we'll need to get debug trace in order to really see where the delay is and troubleshoot this further.


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Thursday, May 10, 2012 8:16 PM
    Moderator
  • Thanks for opening a support incident for this, Fred! I'm still in the loop with the support person who is working with you on that, but I just wanted to officially "close" this thread.

    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Monday, May 14, 2012 8:42 PM
    Moderator