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 add-in's global variables



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 12th 06, 07:33 AM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 17
Default Accessing add-in's global variables

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.

Ads
  #2  
Old September 12th 06, 03:36 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Accessing add-in's global variables

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


wrote in message
ups.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.


  #3  
Old September 12th 06, 05:37 PM posted to microsoft.public.outlook.program_addins
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Accessing add-in's global variables

Also, Jay's sample at http://www.tsbradley.net/Samples/VST...rt.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]" wrote in message ...
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


wrote in message
ups.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.


  #4  
Old September 12th 06, 07:55 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Accessing add-in's global variables

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]" wrote in message
...
Also, Jay's sample at
http://www.tsbradley.net/Samples/VST...rt.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

  #5  
Old September 24th 06, 07:28 AM posted to microsoft.public.outlook.program_addins
Maysam
external usenet poster
 
Posts: 1
Default Accessing add-in's global variables

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);
}

 




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
Add Global Contact List to email find bxb7668 Outlook - Using Contacts 1 June 28th 06 03:56 AM
List of predefined variables morten Outlook - Installation 1 June 2nd 06 02:30 AM
Sessions and Variables Ian Mackenzie Outlook and VBA 1 March 9th 06 03:35 PM
Get values of custom variables from customised contact form Michael Anderson Outlook and VBA 1 February 6th 06 10:06 PM
Add Other Peoples Contacts to Global Address List Sue Mosher [MVP-Outlook] Outlook - Using Contacts 0 January 18th 06 06:08 PM


All times are GMT +1. The time now is 08:13 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.