A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Accessing contact folder Problem



 
 
Thread Tools Search this Thread Display Modes
  #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.

  #2  
Old September 17th 07, 06:03 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Accessing contact folder Problem

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  
Old September 18th 07, 12:46 PM posted to microsoft.public.outlook.program_addins
Alex[_2_]
external usenet poster
 
Posts: 7
Default Accessing contact folder Problem

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  
Old September 18th 07, 03:42 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Accessing contact folder Problem

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  
Old September 18th 07, 05:03 PM posted to microsoft.public.outlook.program_addins
Alex[_2_]
external usenet poster
 
Posts: 7
Default Accessing contact folder Problem

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 09:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.