VSTO Outlook 2007

M

manzoor

Hey I'm using C#, Visual Studio 2005 Professional. I installed VSTO 2005 SE
and its runtime from Microsoft Downloads.

I created a Outlook add-in and in it I added a User Control.

Its code is.

using System;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Runtime.InteropServices;


namespace OutlookAddIn1
{
public partial class UserControl1 : UserControl, Outlook.PropertyPage
{
const int captionDispID = -518;
bool isDirty = false;


public UserControl1()
{
InitializeComponent();
}

void Outlook.PropertyPage.Apply()
{
MessageBox.Show("The user clicked the Apply button");
}

bool Outlook.PropertyPage.Dirty
{
get
{
return isDirty;
}
}

void Outlook.PropertyPage.GetPageInfo(ref string helpFile, ref int
helpContext)
{
}

[DispId(captionDispID)]
public string PageCaption
{
get
{
return "Test Page";
}
}
}
}



Now in the ThisAddIn.cs file (main add in file)

the code is

using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace OutlookAddin1
{
public partial class ThisApplication
{ Outlook.NameSpace nameSpace;

private void ThisApplication_Startup(object sender, EventArgs e)
{
this.OptionsPageAdd += new
Outlook.ApplicationEvents_11_OptionsPagesAddEventHandler(
ThisApplication_OptionsPagesAdd);

nameSpace = this.Session;
nameSpace.OptionsPagesAdd += new
Outlook.NameSpaceEvents_OptionsPagesAddEventHandler(
NameSpace_OptionsPagesAdd);
}

private void ThisApplication_Shutdown(object sender, EventArgs e)
{
}

void ThisApplication_OptionsPagesAdd(Outlook.PropertyPages pages)
{
pages.Add(new UserControl1(), "");
}

void NameSpace_OptionsPagesAdd(Outlook.PropertyPages pages,
Outlook.MAPIFolder folder)
{
pages.Add(new UserControl1(), "");
}

#region VSTO Designer generated code
private void InternalStartup()
{
this.Startup += new EventHandler(ThisApplication_Startup);
this.Shutdown += new EventHandler(ThisApplication_Shutdown);
}
#endregion
}
}




The code is from a book and I get the following errors
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.Designer.cs(71,18): error
CS0117: 'OutlookAddIn1.ThisAddIn' does not contain a definition for
'InternalStartup'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(14,18): error CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for
'OptionsPageAdd'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(18,30): error CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for 'Session'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(30,27): error CS0246:
The type or namespace name 'UserControl1' could not be found (are you missing
a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(30,13): error CS1502:
The best overloaded method match for
'Microsoft.Office.Interop.Outlook.PropertyPages.Add(object, string)' has some
invalid arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(30,23): error CS1503:
Argument '1': cannot convert from 'UserControl1' to 'object'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(36,27): error CS0246:
The type or namespace name 'UserControl1' could not be found (are you missing
a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(36,13): error CS1502:
The best overloaded method match for
'Microsoft.Office.Interop.Outlook.PropertyPages.Add(object, string)' has some
invalid arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(36,23): error CS1503:
Argument '1': cannot convert from 'UserControl1' to 'object'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(42,18): error CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for 'Startup'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(43,18): error CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for 'Shutdown'


What am I doing wrong?
 
K

Ken Slovak - [MVP - Outlook]

That's not code for a VSTO 2005 SE addin, it's code for a VSTO 2005 addin.

You have either the wrong version of VSTO installed or are using addin code
for the earlier version.

ThisApplication_Startup() is from VSTO 2005, in VSTO 2005 SE it would be
ThisAddin_Startup().




manzoor said:
Hey I'm using C#, Visual Studio 2005 Professional. I installed VSTO 2005
SE
and its runtime from Microsoft Downloads.

I created a Outlook add-in and in it I added a User Control.

Its code is.

using System;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Runtime.InteropServices;


namespace OutlookAddIn1
{
public partial class UserControl1 : UserControl, Outlook.PropertyPage
{
const int captionDispID = -518;
bool isDirty = false;


public UserControl1()
{
InitializeComponent();
}

void Outlook.PropertyPage.Apply()
{
MessageBox.Show("The user clicked the Apply button");
}

bool Outlook.PropertyPage.Dirty
{
get
{
return isDirty;
}
}

void Outlook.PropertyPage.GetPageInfo(ref string helpFile, ref int
helpContext)
{
}

[DispId(captionDispID)]
public string PageCaption
{
get
{
return "Test Page";
}
}
}
}



Now in the ThisAddIn.cs file (main add in file)

the code is

using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace OutlookAddin1
{
public partial class ThisApplication
{ Outlook.NameSpace nameSpace;

private void ThisApplication_Startup(object sender, EventArgs e)
{
this.OptionsPageAdd += new
Outlook.ApplicationEvents_11_OptionsPagesAddEventHandler(
ThisApplication_OptionsPagesAdd);

nameSpace = this.Session;
nameSpace.OptionsPagesAdd += new
Outlook.NameSpaceEvents_OptionsPagesAddEventHandler(
NameSpace_OptionsPagesAdd);
}

private void ThisApplication_Shutdown(object sender, EventArgs e)
{
}

void ThisApplication_OptionsPagesAdd(Outlook.PropertyPages pages)
{
pages.Add(new UserControl1(), "");
}

void NameSpace_OptionsPagesAdd(Outlook.PropertyPages pages,
Outlook.MAPIFolder folder)
{
pages.Add(new UserControl1(), "");
}

#region VSTO Designer generated code
private void InternalStartup()
{
this.Startup += new EventHandler(ThisApplication_Startup);
this.Shutdown += new EventHandler(ThisApplication_Shutdown);
}
#endregion
}
}




The code is from a book and I get the following errors
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.Designer.cs(71,18):
error
CS0117: 'OutlookAddIn1.ThisAddIn' does not contain a definition for
'InternalStartup'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(14,18): error
CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for
'OptionsPageAdd'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(18,30): error
CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for
'Session'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(30,27): error
CS0246:
The type or namespace name 'UserControl1' could not be found (are you
missing
a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(30,13): error
CS1502:
The best overloaded method match for
'Microsoft.Office.Interop.Outlook.PropertyPages.Add(object, string)' has
some
invalid arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(30,23): error
CS1503:
Argument '1': cannot convert from 'UserControl1' to 'object'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(36,27): error
CS0246:
The type or namespace name 'UserControl1' could not be found (are you
missing
a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(36,13): error
CS1502:
The best overloaded method match for
'Microsoft.Office.Interop.Outlook.PropertyPages.Add(object, string)' has
some
invalid arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(36,23): error
CS1503:
Argument '1': cannot convert from 'UserControl1' to 'object'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(42,18): error
CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for
'Startup'
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\OutlookAddIn1\OutlookAddIn1\ThisAddIn.cs(43,18): error
CS0117:
'OutlookAddin1.ThisApplication' does not contain a definition for
'Shutdown'


What am I doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top