Which statement raises the error?
You probably should use Folder instead of MAPIFolder, given that you're coding for Outlook 2007.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"Naji" wrote in message ...
Good Morning Sue,
Here is the link to the sample I am experimenting with:
http://www.microsoft.com/downloads/d...displaylang=en
and here is some of the code I am put together:
1 private void ThisAddIn_Startup(object sender, System.EventArgs e)
2 {
3 Outlook.MAPIFolder customPropFolder =
CustomPropertiesFolder(this.Application.Session);
4
5 if (customPropFolder != null)
6 {
7 customPropFolder.WebViewURL =
RegisterFolderHomepage.RegisterType(typeof(FolderH omepageUC),
customPropFolder.Name);
8 customPropFolder.WebViewOn = true;
9 customPropFolder.Display();
10 }
11 }
12
13 private Outlook.MAPIFolder CustomPropertiesFolder(Outlook.NameSpace
session)
15 {
16 string folderName = "Special Folder";
17 Outlook.MAPIFolder rootFolder =
(Outlook.MAPIFolder)session.GetDefaultFolder(Outlo ok.OlDefaultFolders.olFolderInbox).Parent;
18 Outlook.MAPIFolder customPropFolder = null;
19 foreach (Outlook.MAPIFolder _folder in rootFolder.Folders)
20 {
21 if (_folder.Name == folderName)
22 customPropFolder = _folder;
23 }
24
25 try
26 {
27 if (customPropFolder == null)
28 {
29 customPropFolder = rootFolder.Folders.Add(folderName,
Outlook.OlDefaultFolders.olFolderInbox);
30 }
31 }
32 catch (Exception ex)
33 {
34 System.Windows.Forms.MessageBox.Show(ex.Message);
35 }
36
37 return customPropFolder;
38 }
All I am doing to the sample (at the link provided above) is changing the
occurrences of "Outlook.OlDefaultFolders.olFolderTasks" to
"Outlook.OlDefaultFolders.olFolderInbox". Before the change, the sample works
fine, but after the change it breaks.
If I can get the sample to behave properly, my problem (to add a folder
with a custom homepage to the root folder) would be solved.
I am using VS 2008 and Outlook 2007
Please advise as to the best way to achieve the following:
1) I want to be able to click on a button that resides in the Explorer
Toolbar, and display a custom explorer window with different controls.
I have already tried to follow the steps outlined in this sample:
"OutlookAddin_FolderHomepageView_Sample", but, in my case, it seems to work
only for the Tasks Folder, but it would not work for the Default Inbox
folder. I keep getting: "Object does not support this property or method"