没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
by Ayman Hourieh | March 2009 | Open Source Web Development
Microsoft Office Outlook is one of the world's most widely-used personal information management tool.
Primarily, the Microsoft Office Outlook serves as an email application for a wide range of users. In this
article by Vivek Thangaswamy, you will learn the concepts of programming for Microsoft Office Outlook
2007 using VSTO 3.0 and C#. We will take a look at the following:
An overview of the Outlook object model and its features in VSTO
Learning the extensibility of Microsoft Office Outlook 2007 using the object model
Learning to customize Microsoft Office Outlook menus and toolbars using VSTO
Working with form regions in Outlook, manipulating folders, contact information, and mail items
using VSTO programming
Microsoft Office Outlook object model overview
Programming in Microsoft Office Outlook differs from programming other Microsoft applications such as
InfoPath and Excel. Most of the Microsoft Office applications target documents rather than data items,
but Microsoft Office Outlook targets each data item stored in the database or the primary data storage
used by an Outlook application. Microsoft Office Outlook stores and manages data items such as
emails, appointments, notes, tasks, and contacts in tables in a structured database.
The Microsoft Office Outlook object model is based on COM (Component Object Model) and is used
to interact with Outlook form regions, menus, and other application customization possibilities. It is
similar to other Microsoft Office application object models when thought of with respect to the object
model implementation interfaces for collections, objects, properties, methods, and events.
COM is a language-neutral way of implementing objects that can be used in different environments.
A large numbers of objects are available for developing and customizing Outlook 2007. If the developer
needs to develop application add-ins for Outlook, he or she can program using the objects provided by
the Outlook object model. In the Outlook object model, the class will represent each object in the UI to
the user. For example, the Microsoft.Office.Interop.Outlook.Application class represents the entire
application, and the Microsoft.Office.Interop.Outlook.MailItem class represents an email message.
To get used to the object models in Outlook, you should be familiar with some of the top-level objects.
The Application object represents an Outlook application, and it is the highest level class in the Outlook
object model. The Explorer object corresponds to the window that displays the contents of a folder, and
contains Outlook data items such as email messages, tasks, appointments, and so on. The MAPIFolder
object represents the folder that contains emails, contacts, tasks, and other Outlook data items. By
default, there are sixteen MAPIFolder objects available. The Inspector object corresponds to a window
that displays a single item such as a particular email message, or a specific contact item.
Let's see how to create application-level add-ins for Microsoft Office Outlook 2007 using VSTO 3.0. We
will create a Hello World application-level example for Microsoft Office Outlook 2007 using Visual
Studio 2008.
1. Open Visual Studio 2008 to create a new Outlook 2007 Add-in template project.
2. Select New Project. Under Office select 2007, and then select the Microsoft Outlook
Add-in template, and name the project as per your requirements.
3. The solution will be created with all of the supporting files required for the development
of Outlook solution, as shown in the following screenshot:
4. Write the following code to display a message box:
// Windows forms namespace to display
Message box
using System.Windows.Forms;
5. Write the code to display the Say Hello World! message while loading:
private void ThisAddIn_Startup(object
sender, System.EventArgs e)
{
// Message box display
MessageBox.Show("Say Hello World!");
}
The result will be similar to what is shown in the following screenshot:
Outlook 2007 object models are categorized and mapped correspondingly. The following Outlook object
models hold all of Outlook's objects for programming in their corresponding object model categories:
Items object model, Navigation bars and Outlook bars object model, Rules object model, and Views
object model. In the Application object model hierarchy, the Application object is the parent of all other
Outlook objects.
Customization using VSTO
Most enterprise business applications are loaded with a wide variety of features for users. Even though
these applications have a wide range of features, many business requirements can be fulfilled only
through customization because not all applications are designed to fit each and every enterprise's
special needs. Customization for most of the application is a tough job to execute.
Outlook 2007 is loaded with a wide variety of features that will satisfy a broad range of user categories.
Some organizations need more functionality and features to be added, so that the application will satisfy
their custom business requirements. VSTO 3.0 helps Office developers to customize and enhance the
Outlook 2007 application as per the user's business requirements.
Microsoft Office Outlook 2007 supports other Microsoft Office tools such as InfoPath
and Excel, in order to provide seamless collaboration.
VSTO provides an easy way to create an application-level add-in for Outlook 2007 using Visual Studio
2008. Creating add-ins for Microsoft Office Outlook 2007 has been more complex to work out, but VSTO
3.0 offers Office developers with project templates in Visual Studio 2008 to allow them to create add-ins
for Outlook 2007. Adding to the project templates, VSTO offers great support for development and
deployment, which improves the development work. This provides .NET framework support for Outlook
2007 add-in programming, which includes class library support, controlled exception handling, memory
management, extensibility, ClickOnce deployment, and so on.
Menus in Outlook
A group of commands or lists of options from which you can choose your desired operation is known as
a menu. Most of the latest applications are menu driven. Microsoft Office Outlook, which is a menu-
driven application, provides the user with an easy fl owing UI for user interaction. Most of the menu-
driven applications will provide you with basic customization such as choosing the menu for the default
view of the application, and so on.
In Microsoft Office, all menus and toolbars are CommandBars. A CommandBar is a
static collection shared by all Windows. There are standard toolbars, menu bars,
context menus, and so on. A small add-in enumerates and displays all Microsoft
Outlook CommandBars.
Likewise, Microsoft Office Outlook 2007 provides the option for a user to customize the menus. VSTO
3.0 provides Office developers with the ability to build custom menus and customize the existing menus
using the .NET framework and support a programming language. You can even rebuild the classic
menu style for Outlook 2007 by using the VSTO 3.0 application level add-ins development.
Let's create a custom menu in the menu bar of the Outlook and add a new item to the menu. This way,
you will get to know about custom menu development for Microsoft Office Outlook 2007.
Open Visual Studio 2008 and create a new solution, as described in the previous example.
Let's write a program to create a menu item and call it Say Hello World.
// Defining new Menubar
private Office.CommandBar PacktOldMenuBar;
// Defining old Menubar
private Office.CommandBarPopup PacktNewMenuBar;
// Defining instance of button for menu item
private Office.CommandBarButton PacktButton1;
// Tag string for our Menu item
private string strMenuString = "Outlook AddIn #1";
private void ThisAddIn_Startup(object sender,
System.EventArgs e)
{
// Define the Old Menu Bar
PacktOldMenuBar = this.Application.ActiveExplorer().
CommandBars.ActiveMenuBar;
// Define the new Menu Bar into the existing menu
bar
PacktNewMenuBar =
(Office.CommandBarPopup)PacktOldMenuBar.
Controls.Add(Office.MsoControlType.msoControlPopup,
missing, missing, missing, false);
//If PacktNewMenuBar not found then the code will
add it
if (PacktNewMenuBar != null)
剩余25页未读,继续阅读
资源评论
- lihuang3192012-07-26可以用,不错
hjp1314258
- 粉丝: 8
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功