Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Outlook Add-in with C#

Geek News

Outlook Add-in with C#
lg 6/27/2006 4:25:01 PM
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.
Re: Outlook Add-in with C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/27/2006 4:42:16 PM
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" <lg[ at ]discussions.microsoft.com> wrote in message
news:227C04DF-C198-4C63-AFEC-16D8E9B5E861[ at ]microsoft.com...
[Quoted Text]
> 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.

Re: Outlook Add-in with C#
lg 6/27/2006 5:24:02 PM
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:

[Quoted Text]
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> news:227C04DF-C198-4C63-AFEC-16D8E9B5E861[ at ]microsoft.com...
> > 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.
>
>
Re: Outlook Add-in with C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/27/2006 6:31:32 PM
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" <lg[ at ]discussions.microsoft.com> wrote in message
news:EC987E52-5DF0-4C2E-B65E-F2245B0124F0[ at ]microsoft.com...
[Quoted Text]
> 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 :)

Re: Outlook Add-in with C#
lg 6/28/2006 10:45:02 AM
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:

[Quoted Text]
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> news:EC987E52-5DF0-4C2E-B65E-F2245B0124F0[ at ]microsoft.com...
> > 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 :)
>
>
Re: Outlook Add-in with C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/28/2006 1:30:35 PM
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" <lg[ at ]discussions.microsoft.com> wrote in message
news:4F7A6DA1-CC96-4782-BEAA-1164BE6275A4[ at ]microsoft.com...
[Quoted Text]
> 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 ?

Re: Outlook Add-in with C#
lg 6/28/2006 3:08:02 PM
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:

[Quoted Text]
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> news:4F7A6DA1-CC96-4782-BEAA-1164BE6275A4[ at ]microsoft.com...
> > 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 ?
>
>
Re: Outlook Add-in with C#
lg 6/29/2006 9:24:01 AM
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:

[Quoted Text]
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> > news:4F7A6DA1-CC96-4782-BEAA-1164BE6275A4[ at ]microsoft.com...
> > > 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 ?
> >
> >
Re: Outlook Add-in with C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/29/2006 1:35:46 PM
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" <lg[ at ]discussions.microsoft.com> wrote in message
news:8C07C809-9481-4885-9ECF-AC2EA3081CAC[ at ]microsoft.com...
[Quoted Text]
> 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.

Re: Outlook Add-in with C#
lg 6/29/2006 4:01:02 PM
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:

[Quoted Text]
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> news:8C07C809-9481-4885-9ECF-AC2EA3081CAC[ at ]microsoft.com...
> > 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.
>
>
Re: Outlook Add-in with C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/29/2006 7:45:59 PM
One-off forms encapsulate the form design within the form so they are much
bigger than a form that's not one-offed. They can't run code that might be
behind the form. Since they don't use a published form they cannot respond
to any updates, they always will have the design that was embedded.

There are a number of other problems with one-offed forms. See
http://www.outlookcode.com/d/formpub.htm#oneoff for a list of various
problems you can create that way.

--
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" <lg[ at ]discussions.microsoft.com> wrote in message
news:F02AC959-79A9-45A2-B6E0-6EFF8F6B7C9A[ at ]microsoft.com...
[Quoted Text]
>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 ?

Re: Outlook Add-in with C#
lg 6/30/2006 10:04:02 AM
Is it possible to publish the appointmentitem after the tab and controls are
added C# addin to provent one offs ? or to do something like in that article
(the link in your last post) to clean to appointmentItem so it's not a one
off form ?

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

[Quoted Text]
> One-off forms encapsulate the form design within the form so they are much
> bigger than a form that's not one-offed. They can't run code that might be
> behind the form. Since they don't use a published form they cannot respond
> to any updates, they always will have the design that was embedded.
>
> There are a number of other problems with one-offed forms. See
> http://www.outlookcode.com/d/formpub.htm#oneoff for a list of various
> problems you can create that way.
>
> --
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> news:F02AC959-79A9-45A2-B6E0-6EFF8F6B7C9A[ at ]microsoft.com...
> >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 ?
>
>
Re: Outlook Add-in with C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/30/2006 9:19:14 PM
Just design the form and publish it using C# code. Make sure it's included
in your installation. Don't ask for problems and if you do don't ask for
sympathy when they happen. If you add a control to a form using code it's
one-offed.

--
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" <lg[ at ]discussions.microsoft.com> wrote in message
news:1305685C-E572-4631-AAC4-05346D1B33A0[ at ]microsoft.com...
[Quoted Text]
> Is it possible to publish the appointmentitem after the tab and controls
> are
> added C# addin to provent one offs ? or to do something like in that
> article
> (the link in your last post) to clean to appointmentItem so it's not a one
> off form ?

Re: Outlook Add-in with C#
lg 7/4/2006 4:13:02 PM
Thanks for the help Ken

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

[Quoted Text]
> Just design the form and publish it using C# code. Make sure it's included
> in your installation. Don't ask for problems and if you do don't ask for
> sympathy when they happen. If you add a control to a form using code it's
> one-offed.
>
> --
> 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" <lg[ at ]discussions.microsoft.com> wrote in message
> news:1305685C-E572-4631-AAC4-05346D1B33A0[ at ]microsoft.com...
> > Is it possible to publish the appointmentitem after the tab and controls
> > are
> > added C# addin to provent one offs ? or to do something like in that
> > article
> > (the link in your last post) to clean to appointmentItem so it's not a one
> > off form ?
>
>

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