In continuation to my earlier post on creating an Outlook store, today I shall show you how to create custom folders for the store .
I started off by trying the MSDN way, and am providing the code below. The myStore refers to the Outlook.MAPIFolder which represents the custom store.
myStore.Folders.Add("First Folder", olFolderInbox);
myStore.Folders.Add("Second Folder", olFolderInbox);
While the first line created the folder for me , the second line greeted me with an execption "Invalid argument type" . I tried replacing the olFolderInbox parameter with the other permissible parameters of OlDefaultFolders, but without success .It took me some time to solve this problem , but what I learnt was interesting.
If you look at the Folders.Add(Name,Type ) method you shall see that the Type is an optional parameter, and if you have not worked with Office Automation earlier in C#, you might be wondering how to populate the default parameter; and there was the problem .
Showing posts with label Outlook Addins. Show all posts
Showing posts with label Outlook Addins. Show all posts
Sunday, February 14, 2010
Sunday, January 24, 2010
Creating a Outlook store programatically
Office programming has become much easier with Visual Studio for Office. Though the object model still needs to be know, but there is less of COM plumbing, and helper classes to make life easier .
Among the entire Office suite family, Outlook is probably the most used , and hence users prefer addins which can connect to other external applications, be it CRM or fetching data from web service and displaying in the Outlook dashboard
If you are really serious about Office Development, you should get a copy of Add In Express, which makes office development very easy . The Addin Express team has been kind enough to provide a 10% discount to the readers of this blogs and so you can grab a copy of Add In Express ( Standard , Professional, Premium ) at http://www.add-in-express.com/purchase/index.php using the discount coupon ADX-GSUJAY-ADX10.
The following code creates a MAPIStore programmmatically. I have used C# as the language. Though I have worked with MAPI , ( Simple and Extended MAPI ) with C++/COM, if you dont need Extended MAPI , C# is just fine . But again remember , that the entire Office Suie is unmanaged code, and C# is managed code , so you may have to do marshalling sometimes .
Outlook.NameSpace olNamespace = OutlookApp.GetNamespace("MAPI");
// Get the Default Inbox folder
Outlook.MAPIFolder olMapiFolder = olNamespace.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder olCustomFolder;
string path = "C:\\mydata.pst";
// Create a store
Among the entire Office suite family, Outlook is probably the most used , and hence users prefer addins which can connect to other external applications, be it CRM or fetching data from web service and displaying in the Outlook dashboard
If you are really serious about Office Development, you should get a copy of Add In Express, which makes office development very easy . The Addin Express team has been kind enough to provide a 10% discount to the readers of this blogs and so you can grab a copy of Add In Express ( Standard , Professional, Premium ) at http://www.add-in-express.com/purchase/index.php using the discount coupon ADX-GSUJAY-ADX10.
The following code creates a MAPIStore programmmatically. I have used C# as the language. Though I have worked with MAPI , ( Simple and Extended MAPI ) with C++/COM, if you dont need Extended MAPI , C# is just fine . But again remember , that the entire Office Suie is unmanaged code, and C# is managed code , so you may have to do marshalling sometimes .
Outlook.NameSpace olNamespace = OutlookApp.GetNamespace("MAPI");
// Get the Default Inbox folder
Outlook.MAPIFolder olMapiFolder = olNamespace.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder olCustomFolder;
string path = "C:\\mydata.pst";
// Create a store
Labels:
Addin Express
,
C#
,
MAPI
,
Office Development
,
Outlook Addins
,
Outlook Development
,
Programming Outlook
,
VSTO
Wednesday, December 23, 2009
Develop Office Addins in a breeze – Part 1
Five years back I was working on a product, which included Word automation. The task was simple ; let the user create a new Word document from within the product . The product was being developed in Visual C++ 6.0 and there was no VSTO . The key idea behind this feature was Office integration . I had done this using Word automation and COM plumbing with the Word Object Model.
If you are new to Offiice Development ; and interested in getting a quick overview, I would recommend VSTO 3.0 for Office 2007 Programming
. On the other hand if you want to get more deep , I would recommend Visual Studio Tools for Office 2007: VSTO for Excel, Word, and Outlook
.
Why Office Add - Ins
Things have changed in the last 5 years. Visual C++ 6 has been replaced by the Visual Studio suite, Windows Programming has become much easier, .NET has evolved, global economy has gone north and new innovative and useful products have made development easier.
Maybe if I was developing the same product today, the concept might have been different . My boss would have probably told me , “Hey , why not develop a product specific menu in the Word application itself, so the user can directly talk to our app while using Word”. This approach makes much sense, as it not only addresses our need, but also makes the user feel more comfortable ( he doesn't have to start our application to access the specific features )
So I would have landed developing a Word Add-in , maybe using Visual Studio Professional Edition ( Extensibility –> Shared Add In Project ) or Visual Studio for Office ( haven’t used it ever ) .
If you are new to Offiice Development ; and interested in getting a quick overview, I would recommend VSTO 3.0 for Office 2007 Programming
Why Office Add - Ins
Things have changed in the last 5 years. Visual C++ 6 has been replaced by the Visual Studio suite, Windows Programming has become much easier, .NET has evolved, global economy has gone north and new innovative and useful products have made development easier.
Maybe if I was developing the same product today, the concept might have been different . My boss would have probably told me , “Hey , why not develop a product specific menu in the Word application itself, so the user can directly talk to our app while using Word”. This approach makes much sense, as it not only addresses our need, but also makes the user feel more comfortable ( he doesn't have to start our application to access the specific features )
So I would have landed developing a Word Add-in , maybe using Visual Studio Professional Edition ( Extensibility –> Shared Add In Project ) or Visual Studio for Office ( haven’t used it ever ) .
Labels:
.NET
,
Addin Express
,
C#
,
C++
,
Extensibility
,
Office
,
Office Development
,
Outlook Addins
,
Outlook Development
,
Product review
,
Programming Outlook
,
RAD Tool
,
Visual Studio
,
VSTO
Subscribe to:
Comments
(
Atom
)