Use the trusted Application passed to you in OnConnection, never use a new
Application object, that isn't trusted.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Alex" wrote in message
oups.com...
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.