Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Accessing add-in's global variables

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Accessing add-in's global variables
cookiesncreamychoc[ at ]hotmail.com 12.09.2006 05:33:53
Hi,

This probably isnt possible but...
I have an Outlook add-in that requests username and password (these are
not the active directory credentials but are related to another
application) when Outlook first starts. Once authenticated (against
username and password in a database), the ID for the user is saved as a
global variable in the add-in for future use.

I also have a Windows application that launches outlook when a certain
button is clicked. I need to check the userID of the user logged into
Outlook. Is there a way to access global variable of the add-in from
another application?

Alternatively, can I save the userID as a session variable in Outlook?

Thanx in advance

P.S. Both the application and add-in are written in VB (VS2005) but the
add-in does NOT use VSTO.

Re: Accessing add-in's global variables
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 12.09.2006 13:36:16
I haven't done this with any VB.NET addins so I'm not sure it will work
there but in a standard COM addin using VB 6 one way is to expose your
global in the designer (the class that implements IDTExtensibility2 and
handles OnConnection). The global can be exposed as a public property.

You can then iterate the Outlook.Application.COMAddins collection looking at
the ProgID properties of each addin until you find yours. You can then
access the global property from there.

The code would look something like this:

Dim m_oAddinBase As Object
Dim lngID As Integer

m_oAddinBase = g_objOL.COMAddIns("MyAddin.Connect").Object
lngID = m_oAddinBase.UserID

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


<cookiesncreamychoc[ at ]hotmail.com> wrote in message
news:1158039233.789923.128970[ at ]i3g2000cwc.googlegroups.com...
[Quoted Text]
> Hi,
>
> This probably isnt possible but...
> I have an Outlook add-in that requests username and password (these are
> not the active directory credentials but are related to another
> application) when Outlook first starts. Once authenticated (against
> username and password in a database), the ID for the user is saved as a
> global variable in the add-in for future use.
>
> I also have a Windows application that launches outlook when a certain
> button is clicked. I need to check the userID of the user logged into
> Outlook. Is there a way to access global variable of the add-in from
> another application?
>
> Alternatively, can I save the userID as a session variable in Outlook?
>
> Thanx in advance
>
> P.S. Both the application and add-in are written in VB (VS2005) but the
> add-in does NOT use VSTO.
>

Re: Accessing add-in's global variables
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 12.09.2006 15:37:31
Also, Jay's sample at http://www.tsbradley.net/Samples/VSTO/Xml.Export.Sample.aspx shows some of the tricky bits required to make a .NET add-in's properties and methods available to external callers.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> wrote in message news:%23jXa4Bn1GHA.5048[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
>I haven't done this with any VB.NET addins so I'm not sure it will work
> there but in a standard COM addin using VB 6 one way is to expose your
> global in the designer (the class that implements IDTExtensibility2 and
> handles OnConnection). The global can be exposed as a public property.
>
> You can then iterate the Outlook.Application.COMAddins collection looking at
> the ProgID properties of each addin until you find yours. You can then
> access the global property from there.
>
> The code would look something like this:
>
> Dim m_oAddinBase As Object
> Dim lngID As Integer
>
> m_oAddinBase = g_objOL.COMAddIns("MyAddin.Connect").Object
> lngID = m_oAddinBase.UserID
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> <cookiesncreamychoc[ at ]hotmail.com> wrote in message
> news:1158039233.789923.128970[ at ]i3g2000cwc.googlegroups.com...
>> Hi,
>>
>> This probably isnt possible but...
>> I have an Outlook add-in that requests username and password (these are
>> not the active directory credentials but are related to another
>> application) when Outlook first starts. Once authenticated (against
>> username and password in a database), the ID for the user is saved as a
>> global variable in the add-in for future use.
>>
>> I also have a Windows application that launches outlook when a certain
>> button is clicked. I need to check the userID of the user logged into
>> Outlook. Is there a way to access global variable of the add-in from
>> another application?
>>
>> Alternatively, can I save the userID as a session variable in Outlook?
>>
>> Thanx in advance
>>
>> P.S. Both the application and add-in are written in VB (VS2005) but the
>> add-in does NOT use VSTO.
>>
>
Re: Accessing add-in's global variables
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 12.09.2006 17:55:17
Ah, thanks, Sue. I had forgotten Jay had done a sample that did that for
VB.NET.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> wrote in message
news:OZ3K7Po1GHA.1548[ at ]TK2MSFTNGP02.phx.gbl...
Also, Jay's sample at
http://www.tsbradley.net/Samples/VSTO/Xml.Export.Sample.aspx shows some of
the tricky bits required to make a .NET add-in's properties and methods
available to external callers.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

Re: Accessing add-in's global variables
"Maysam" <m_karbala[ at ]yahoo.com> 24.09.2006 05:28:22
Hi
I have done this in excel.

1- you have to make sure that you application is visible by com.
2- create an instance of your application
3- create an instance of your addin
4- using invoke method you can have access to your public property.

step 2
app = new Excel.Application();

step 3
object sAddInName = "SimulationSmartClientAddIN.Connect";
object objApp_addin = app.COMAddIns.Item(ref sAddInName).Object;

step 4
to set a property:SetProperty(objApp_addin, "<PropertyName>", <Value>);
to get a property:SetProperty(objApp_addin, "<PropertyName>");


private void SetProperty(object obj, string sProperty, object oValue)
{
object[] oParam = new object[1];
oParam[0] = oValue;
obj.GetType().InvokeMember(sProperty,
System.Reflection.BindingFlags.SetProperty, null, obj, oParam);
}

private static object GetProperty(object obj, string sProperty)
{
return obj.GetType().InvokeMember(sProperty,
System.Reflection.BindingFlags.GetProperty, null, obj, null);
}

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net