|
Jack Bretcher
Posts: 189
Joined: 2006-06-30
|
I have a very basic question. I just purchased and loaded Add-in-Express and at the same time am making the transition from VB6 to .NET for my Outlook COM development.
In the past when I initialized my addin (in InitHandler) I set a global to the passed in Outlook Object. I then used this to access the Outlook object from the rest of my code.
How do I do that in this environment?
Jack |
|
Posted 30 Jun, 2006 22:26:48
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Jack.
You can use the HostApplication property of the AddinModule class to access the Outlook application object. |
|
Posted 03 Jul, 2006 06:19:54
|
|
Top
|
|
Jack Bretcher
Posts: 189
Joined: 2006-06-30
|
For some reason I cannot find the HostApplication property of the AddinMOdule class. I see it in the object browser but if I try to reference it in the code it tells me that it is not defined. |
|
Posted 03 Jul, 2006 09:25:28
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Jack, please look at our examples from the ADX installation package.
You will see how we use this property. |
|
Posted 03 Jul, 2006 09:53:48
|
|
Top
|
|
Jack Bretcher
Posts: 189
Joined: 2006-06-30
|
I must be missing something. I looked at the projects in "C:\Program Files\Afalinasoft\Add-in Express .NET\QDemo\VS.NET 2005\" but the only reference to HostApplication is in the following declaration (at bottom of post). I cannot find where is it used in the application.
All I am trying to do is load a form and on that form access the Outlook object to get the default folders.
private Outlook._Application OutlookApp
{
get
{
return HostApplication as Outlook._Application;
}
} |
|
Posted 03 Jul, 2006 10:38:38
|
|
Top
|
|
fearlessfrog
Posts: 56
Joined: 2006-06-27
|
Hi Jack
I use the following event in the Form contructor:
private Outlook.Application _app = null;
public ADXOlForm1()
{
// This call is required by the Windows Form Designer.
InitializeComponent();
this.ADXAfterFormShow +=new AddinExpress.OL.ADXOlForm.AfterFormShow_EventHandler(ADXOlForm1_ADXAfterFormShow);
}
and then use the setup OutlookAppObj in the event...
private void ADXOlForm1_ADXAfterFormShow()
{
_app = (Outlook.Application) this.OutlookAppObj;
// Use the Outlook application object however you like...
}
Not sure if that's the only/best way, but it works for me... |
|
Posted 03 Jul, 2006 13:14:07
|
|
Top
|
|
Jack Bretcher
Posts: 189
Joined: 2006-06-30
|
Here is what I did:
In a module I declared the following global
Then in the Addin AddinStartUpcomplete I added
gOutlook = OutlookApp
Code:
--> In the module
Imports Interop.Outlook
Module Module1
Public gOutlook As Interop.Outlook.Application
End Module
--> in the Addin
Private Sub AddinModule_AddinStartupComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.AddinStartupComplete
eventObject = New OutlookItemsEventsClass1(Me)
gOutlook = OutlookApp
End Sub
This seems to work....
Jack |
|
Posted 03 Jul, 2006 16:19:52
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Jack.
You do everything correct. |
|
Posted 03 Jul, 2006 18:24:27
|
|
Top
|
|
Jack Bretcher
Posts: 189
Joined: 2006-06-30
|
Thanks! BTW, I love your lib's they have saved me many hours vs manually coding as I did in the past. They also make it feasable to move to the DotNet platform!
Jack |
|
Posted 04 Jul, 2006 00:12:44
|
|
Top
|
|