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

Outlook Add-in with C#



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 27th 06, 06:25 PM posted to microsoft.public.outlook.program_addins
lg
external usenet poster
 
Posts: 26
Default Outlook Add-in with C#

Hi,
I am trying to add a new form tab to the Appointments Item in Outlook.
Is it possible to do this using C# in VSTO (Adding controls, Publishing the
form, etc) ? Also is it possible to access the controls with C#, I know it
can be done in VB by using:

item.ModifiedFormPages["Test"].Controls

but is it possible to do it in C# ? and if so how is it done Thanks.
Ads
  #2  
Old June 27th 06, 06:42 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Add-in with C#

If you add a tab (actually make use of a tab that is already there) you will
one-off the form, which is bad. The best thing is to design the custom form
in the forms designer.

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


"lg" wrote in message
...
Hi,
I am trying to add a new form tab to the Appointments Item in
Outlook.
Is it possible to do this using C# in VSTO (Adding controls, Publishing
the
form, etc) ? Also is it possible to access the controls with C#, I know it
can be done in VB by using:

item.ModifiedFormPages["Test"].Controls

but is it possible to do it in C# ? and if so how is it done Thanks.


  #3  
Old June 27th 06, 07:24 PM posted to microsoft.public.outlook.program_addins
lg
external usenet poster
 
Posts: 26
Default Outlook Add-in with C#

Hi Ken,
I think it might work if I customize the form using the forms
designer but I will still need to be able to access the controls on the new
tab. For example, I create a new tab (on the appointmentItem) called "Extra
Details" and add a combo box and a text box. How do I access these control
using C# with VSTO ? Thanks of the help



"Ken Slovak - [MVP - Outlook]" wrote:

If you add a tab (actually make use of a tab that is already there) you will
one-off the form, which is bad. The best thing is to design the custom form
in the forms designer.

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


"lg" wrote in message
...
Hi,
I am trying to add a new form tab to the Appointments Item in
Outlook.
Is it possible to do this using C# in VSTO (Adding controls, Publishing
the
form, etc) ? Also is it possible to access the controls with C#, I know it
can be done in VB by using:

item.ModifiedFormPages["Test"].Controls

but is it possible to do it in C# ? and if so how is it done Thanks.



  #4  
Old June 27th 06, 08:31 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Add-in with C#

Something along the lines of this should work.

First, set a reference to the COM library MS Forms 2.0 (the controls, pages,
etc. for Outlook forms).

Then, in your VSTO code (I'm showing this as part of the startup procedure,
it can be anywhere you need to work with the controls). I just used
ActiveInspector, assuming it was the custom form needed. But the code should
work as an example, and made up control names.

public partial class ThisApplication
{

private Outlook.Application m_Application;

private Outlook.Inspector oInsp;

private OLForms.Pages colPages;

private OLForms.Page oPage;

private OLForms.Controls colControls;



private void ThisApplication_Startup(object sender, System.EventArgs
e)

{

OLForms.TextBox oTBox;

OLForms.ComboBox oCombo;



m_Application = application as Outlook.Application;



oInsp=m_Application.ActiveInspector;



colPages = oInsp.ModifiedFormPages;

oPage = colPages.Item("MyPage");

colControls = oPage.Controls;

oTBox = colControls.Item("MyTextBox");

oCombo = colControls.Item("MyCombo);

From there the oTBox and oCombo objects expose all the properties exposed by
text box and combo box controls.

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


"lg" wrote in message
...
Hi Ken,
I think it might work if I customize the form using the forms
designer but I will still need to be able to access the controls on the
new
tab. For example, I create a new tab (on the appointmentItem) called
"Extra
Details" and add a combo box and a text box. How do I access these control
using C# with VSTO ? Thanks of the help


  #5  
Old June 28th 06, 12:45 PM posted to microsoft.public.outlook.program_addins
lg
external usenet poster
 
Posts: 26
Default Outlook Add-in with C#

This might seem like a bit of a dumb question, I added the reference "MS
Forms 2.0" to the project but the Visual Studio dos'nt seem to recognize
OLForms as a valid namespace, am I missing some else ?

"Ken Slovak - [MVP - Outlook]" wrote:

Something along the lines of this should work.

First, set a reference to the COM library MS Forms 2.0 (the controls, pages,
etc. for Outlook forms).

Then, in your VSTO code (I'm showing this as part of the startup procedure,
it can be anywhere you need to work with the controls). I just used
ActiveInspector, assuming it was the custom form needed. But the code should
work as an example, and made up control names.

public partial class ThisApplication
{

private Outlook.Application m_Application;

private Outlook.Inspector oInsp;

private OLForms.Pages colPages;

private OLForms.Page oPage;

private OLForms.Controls colControls;



private void ThisApplication_Startup(object sender, System.EventArgs
e)

{

OLForms.TextBox oTBox;

OLForms.ComboBox oCombo;



m_Application = application as Outlook.Application;



oInsp=m_Application.ActiveInspector;



colPages = oInsp.ModifiedFormPages;

oPage = colPages.Item("MyPage");

colControls = oPage.Controls;

oTBox = colControls.Item("MyTextBox");

oCombo = colControls.Item("MyCombo);

From there the oTBox and oCombo objects expose all the properties exposed by
text box and combo box controls.

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


"lg" wrote in message
...
Hi Ken,
I think it might work if I customize the form using the forms
designer but I will still need to be able to access the controls on the
new
tab. For example, I create a new tab (on the appointmentItem) called
"Extra
Details" and add a combo box and a text box. How do I access these control
using C# with VSTO ? Thanks of the help



  #6  
Old June 28th 06, 03:30 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Add-in with C#

My bad. I left out some alias declarations in the "using" section before the
start of class ThisApplication:

using Outlook = Microsoft.Office.Interop.Outlook;
using OLForms = Microsoft.Vbe.Interop.Forms;
using Office = Microsoft.Office.Core;

etc.

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


"lg" wrote in message
...
This might seem like a bit of a dumb question, I added the reference "MS
Forms 2.0" to the project but the Visual Studio dos'nt seem to recognize
OLForms as a valid namespace, am I missing some else ?


  #7  
Old June 28th 06, 05:08 PM posted to microsoft.public.outlook.program_addins
lg
external usenet poster
 
Posts: 26
Default Outlook Add-in with C#

I got the OLFroms working now thanks, but I am still having a problem with
getting a handle to the pages in the inspector. With the line of code:

colPages = oInsp.ModifiedFormPages;

I had to type cast "oInsp.ModifiedFormPages" because the ModifiedFormPages
property returns an object. When I type cast it to "Outlook.Pages" it works
alright but if I type cast it "OLForms.Pages" it dosnt work. Do you have any
sugguestions around this ?

"Ken Slovak - [MVP - Outlook]" wrote:

My bad. I left out some alias declarations in the "using" section before the
start of class ThisApplication:

using Outlook = Microsoft.Office.Interop.Outlook;
using OLForms = Microsoft.Vbe.Interop.Forms;
using Office = Microsoft.Office.Core;

etc.

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


"lg" wrote in message
...
This might seem like a bit of a dumb question, I added the reference "MS
Forms 2.0" to the project but the Visual Studio dos'nt seem to recognize
OLForms as a valid namespace, am I missing some else ?



  #8  
Old June 29th 06, 11:24 AM posted to microsoft.public.outlook.program_addins
lg
external usenet poster
 
Posts: 26
Default Outlook Add-in with C#

Hi Ken,
I found what was wrong, I had to type cast it to Outlook.Pages then
when I have the pages object call the page I want and type cast that to
OLForms.UserForms, eg: UserForm = (OLForms.UserForms) pages["Item"]; I have
another question that you might be able to help with. I am trying to add the
tab to the appointment item, now I can add the tab (page) but it is not been
made visible, I can only see it in design mode on the form. Do you know how
to make it visible ? Thanks for the help.

"lg" wrote:

I got the OLFroms working now thanks, but I am still having a problem with
getting a handle to the pages in the inspector. With the line of code:

colPages = oInsp.ModifiedFormPages;

I had to type cast "oInsp.ModifiedFormPages" because the ModifiedFormPages
property returns an object. When I type cast it to "Outlook.Pages" it works
alright but if I type cast it "OLForms.Pages" it dosnt work. Do you have any
sugguestions around this ?

"Ken Slovak - [MVP - Outlook]" wrote:

My bad. I left out some alias declarations in the "using" section before the
start of class ThisApplication:

using Outlook = Microsoft.Office.Interop.Outlook;
using OLForms = Microsoft.Vbe.Interop.Forms;
using Office = Microsoft.Office.Core;

etc.

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


"lg" wrote in message
...
This might seem like a bit of a dumb question, I added the reference "MS
Forms 2.0" to the project but the Visual Studio dos'nt seem to recognize
OLForms as a valid namespace, am I missing some else ?



  #9  
Old June 29th 06, 03:35 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Add-in with C#

Have you tried setting the Visible property? The Object Browser will show
you everything available for any object.

If you're making these customizations using code I still say that's the
worst thing you could do. It will one-off the forms, causing all sorts of
problems.

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


"lg" wrote in message
...
Hi Ken,
I found what was wrong, I had to type cast it to Outlook.Pages then
when I have the pages object call the page I want and type cast that to
OLForms.UserForms, eg: UserForm = (OLForms.UserForms) pages["Item"]; I
have
another question that you might be able to help with. I am trying to add
the
tab to the appointment item, now I can add the tab (page) but it is not
been
made visible, I can only see it in design mode on the form. Do you know
how
to make it visible ? Thanks for the help.


  #10  
Old June 29th 06, 06:01 PM posted to microsoft.public.outlook.program_addins
lg
external usenet poster
 
Posts: 26
Default Outlook Add-in with C#

I got it to work, thanks. Why would this one-off cause a problem, the C# code
is part of an add-in that is installed. So, a user with the add-in installed
sends a meeting request to a user that dosnt have the add-in, the user with
out the add-in just wont see the new tab. Or is this the case ?

"Ken Slovak - [MVP - Outlook]" wrote:

Have you tried setting the Visible property? The Object Browser will show
you everything available for any object.

If you're making these customizations using code I still say that's the
worst thing you could do. It will one-off the forms, causing all sorts of
problems.

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


"lg" wrote in message
...
Hi Ken,
I found what was wrong, I had to type cast it to Outlook.Pages then
when I have the pages object call the page I want and type cast that to
OLForms.UserForms, eg: UserForm = (OLForms.UserForms) pages["Item"]; I
have
another question that you might be able to help with. I am trying to add
the
tab to the appointment item, now I can add the tab (page) but it is not
been
made visible, I can only see it in design mode on the form. Do you know
how
to make it visible ? Thanks for the help.



 




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
my first outlook add-in, in c++... optimist Add-ins for Outlook 3 May 16th 06 05:44 PM
How to add dynamically add controls in Outlook 2003 Rahul Outlook and VBA 5 May 8th 06 03:38 PM
How to add dynamically add controls in Outlook 2003 Sue Mosher [MVP-Outlook] Outlook - Using Forms 4 May 8th 06 03:38 PM
Add-In in Outlook doesn't load any more outl00kalium Add-ins for Outlook 0 January 8th 06 05:49 PM


All times are GMT +1. The time now is 09:07 AM.


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.