![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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. |
#2
|
|||
|
|||
![]()
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. |
#3
|
|||
|
|||
![]()
On Sep 17, 6:03 pm, "Ken Slovak - [MVP - Outlook]"
wrote: 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 Optionshttp://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.OlDefaultFo*lders.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.- Hide quoted text - - Show quoted text - First of all sorry my bad english ... let me explain my Environment and my Application more accurately: My dev environment: Window Vista, Outlook 2007, VSTO SE, VSTOR, VS2005. The step i've made to build the Add-In Architectu Run VS2005 As Administrator, File-New Peoject- in My Template section click on the "Office Outlook 2007 Visual Basic Add-In" button The Following file compose the Defoult solution: addin_register.reg, AssemblyInfo.vb, Connect.vb, OutlookExplorer.vb, OutlookInspector.vb, OutlookItem.vb. I had added to this solution a xml file: customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_OnLoad" ribbon tabs tab idMso="TabReadMessage" group id="joshProtocol" getLabel="WidgetsGroup_GetLabel" visible="1" toggleButton id="toggleTaskPane" size="large" label="Enable Task Pane" screentip="Enable Task Pane" onAction="OnToggleTaskPane" getImage ="GetImage" visible="1" getPressed="GetPressedState" / /group /tab /tabs /ribbon /customUI I had made some change to the file Connector.VB: Implements Office.IRibbonExtensibility Implements Extensibility.IDTExtensibility2 Public Function GetCustomUI(ByVal ...... End Function Public Sub OnConnection(ByVal application As Object, ... End Sub Aplication specific is: Whea a mail message are open (Inspector class, Events Outlook.MailItem.open), the RibbonX is shown and The CustomTaskPane is instanced (As New(ByVal Contact.Email1 String)) the TaskPane constructor accept as parameter a String that is the return value of the function "getMailByName(ByVal Name As String) As String" All of the step explained below are defined in the class Inspector.vb Trusted application Is defined in Connector.vb class, Question: Can i refer to Trusted Aplication in the inspector code? |
#4
|
|||
|
|||
![]()
OK, so your having VSTO is irrelevant in this case, what you have is a
shared addin. You can refer to the Application object in a number of ways from other classes. Either declare an application object as Public in the Connect class or create a public class for your globals and set that in OnConnection: Public app As Outlook.Application ' OnConnection app = CType(application, Outlook.Application) Then from other code you can use Connect.app. -- 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 snip First of all sorry my bad english ... let me explain my Environment and my Application more accurately: My dev environment: Window Vista, Outlook 2007, VSTO SE, VSTOR, VS2005. The step i've made to build the Add-In Architectu Run VS2005 As Administrator, File-New Peoject- in My Template section click on the "Office Outlook 2007 Visual Basic Add-In" button The Following file compose the Defoult solution: addin_register.reg, AssemblyInfo.vb, Connect.vb, OutlookExplorer.vb, OutlookInspector.vb, OutlookItem.vb. I had added to this solution a xml file: customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_OnLoad" ribbon tabs tab idMso="TabReadMessage" group id="joshProtocol" getLabel="WidgetsGroup_GetLabel" visible="1" toggleButton id="toggleTaskPane" size="large" label="Enable Task Pane" screentip="Enable Task Pane" onAction="OnToggleTaskPane" getImage ="GetImage" visible="1" getPressed="GetPressedState" / /group /tab /tabs /ribbon /customUI I had made some change to the file Connector.VB: Implements Office.IRibbonExtensibility Implements Extensibility.IDTExtensibility2 Public Function GetCustomUI(ByVal ...... End Function Public Sub OnConnection(ByVal application As Object, ... End Sub Aplication specific is: Whea a mail message are open (Inspector class, Events Outlook.MailItem.open), the RibbonX is shown and The CustomTaskPane is instanced (As New(ByVal Contact.Email1 String)) the TaskPane constructor accept as parameter a String that is the return value of the function "getMailByName(ByVal Name As String) As String" All of the step explained below are defined in the class Inspector.vb Trusted application Is defined in Connector.vb class, Question: Can i refer to Trusted Aplication in the inspector code? |
#5
|
|||
|
|||
![]()
On Sep 18, 3:42 pm, "Ken Slovak - [MVP - Outlook]"
wrote: OK, so your having VSTO is irrelevant in this case, what you have is a shared addin. You can refer to the Application object in a number of ways from other classes. Either declare an application object as Public in the Connect class or create a public class for your globals and set that in OnConnection: Public app As Outlook.Application ' OnConnection app = CType(application, Outlook.Application) Then from other code you can use Connect.app. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm snip First of all sorry my bad english ... let me explain my Environment and my Application more accurately: My dev environment: Window Vista, Outlook 2007, VSTO SE, VSTOR, VS2005. The step i've made to build the Add-In Architectu Run VS2005 As Administrator, File-New Peoject- in My Template section click on the "Office Outlook 2007 Visual Basic Add-In" button The Following file compose the Defoult solution: addin_register.reg, AssemblyInfo.vb, Connect.vb, OutlookExplorer.vb, OutlookInspector.vb, OutlookItem.vb. I had added to this solution a xml file: customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_OnLoad" ribbon tabs tab idMso="TabReadMessage" group id="joshProtocol" getLabel="WidgetsGroup_GetLabel" visible="1" toggleButton id="toggleTaskPane" size="large" label="Enable Task Pane" screentip="Enable Task Pane" onAction="OnToggleTaskPane" getImage ="GetImage" visible="1" getPressed="GetPressedState" / /group /tab /tabs /ribbon /customUI I had made some change to the file Connector.VB: Implements Office.IRibbonExtensibility Implements Extensibility.IDTExtensibility2 Public Function GetCustomUI(ByVal ...... End Function Public Sub OnConnection(ByVal application As Object, ... End Sub Aplication specific is: Whea a mail message are open (Inspector class, Events Outlook.MailItem.open), the RibbonX is shown and The CustomTaskPane is instanced (As New(ByVal Contact.Email1 String)) the TaskPane constructor accept as parameter a String that is the return value of the function "getMailByName(ByVal Name As String) As String" All of the step explained below are defined in the class Inspector.vb Trusted application Is defined in Connector.vb class, Question: Can i refer to Trusted Aplication in the inspector code? Yes Yes Yes, it work so fine, thanks a lot Mr Ken Slovak --Alessio |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
programs accessing outlook 2002 problem | scubadiver222 | Outlook - General Queries | 1 | January 23rd 07 02:43 PM |
Performance problem by accessing the folder collections | Olivier Langlois | Outlook and VBA | 6 | November 2nd 06 08:20 AM |
Accessing problem to contacts | Mehmet | Outlook - Using Contacts | 1 | September 23rd 06 07:59 PM |
problem accessing HTML account from behind proxy | tytus | Outlook Express | 1 | May 3rd 06 03:38 AM |
Accessing file folder | doughboy | Outlook - Installation | 0 | January 25th 06 11:03 PM |