View Single Post
  #1  
Old September 17th 07, 04:35 PM posted to microsoft.public.outlook.program_addins
Alex[_2_]
external usenet poster
 
Posts: 7
Default Accessing contact folder Problem

In my add-In when i try to find a contact e-mail, with the function
below:

Private Function getMailByName(ByVal Name As String) As String
Dim outlookObject As Outlook._Application = New
Outlook.Application
Dim folder As Outlook.MAPIFolder =
outlookObject.ActiveExplorer().Session.GetDefaultF older(Outlook.OlDefaultFolders.olFolderContacts)
Dim mailAddress As String = String.Empty

Try
For Each contact As Outlook.ContactItem In folder.Items
If contact.FileAs.Contains(Name) Then
mailAddress = contact.Email1Address
Exit For
End If
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
Finally
If outlookObject IsNot Nothing Then outlookObject = Nothing
If folder IsNot Nothing Then folder = Nothing
End Try

Return mailAddress
End Function

I get this alert message:

"A program is trying to access e-mail address information stored in
outlook. If this is unexpected ... "

There is any way to programmatically allow the access to contact
folder.

Ads