为Outlook 2010中创建自定义地址簿编程 [英] Create a custom address book for Outlook 2010 programmatically

查看:274
本文介绍了为Outlook 2010中创建自定义地址簿编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个自定义联系人列表或地址簿,因为它被称为的),以便在Outlook用户将寻求建议联系人, 联系人等,然后,自定义联系人。我去了,并试图以下

 诠释计数= this.Application.GetNamespace(MAPI)AddressLists.Count。 

这给了我8于是,自然而然地,我试图<$ C $价值C> 的东西添加到地址列表对象,但你猜怎么着 - 有没有这样的方法。这没什么奇怪的,因为API明确指出,它是只读的对象。不过,我需要建立一个地址簿/列表(不管它被称为的)为我的客户。



我如何添加一个新的< STRONG>通讯录到Outlook?


解决方案

您可以创建一个 Outlook通讯簿通过使用下面的代码输入:



<预类=郎-CS prettyprint-覆盖> Outlook.Folder接触= this.Application.Session.GetDefaultFolder (Outlook.OlDefaultFolders.olFolderContacts)为Outlook.Folder;
Outlook.Folder通讯录= contacts.Folders.Add(业务联系人,Outlook.OlDefaultFolders.olFolderContacts)为Outlook.Folder;
addressBook.ShowAsOutlookAB = TRUE; //在Outlook通讯簿
Outlook.ContactItem接触力显示= addressBook.Items.Add();
contact.FullName =自定义工业公司;
contact.Email1Address =sales@customindustries.com;
contact.Save();


I'd like to create a Custom Contact List (or address book as it's called) so that in Outlook the user will be looking at "Suggested Contact", "Contacts" etc., and then, "Custom Contacts". I went off and tried the following.

int count = this.Application.GetNamespace("MAPI").AddressLists.Count;

This gives me the value of 8. So, naturally, I've tried to Add something to the address list object but guess what - there's no such method. It's nothing strange about that, since the API clearly states that it's read-only object. However, I need to set up an address book/list (whatever it's called) for my client.

How do I add a new Address Book to Outlook?

解决方案

You can create an Outlook Address Book entry by using the following code:

Outlook.Folder contacts = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;
Outlook.Folder addressBook = contacts.Folders.Add("Business Contacts", Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;
addressBook.ShowAsOutlookAB = true; // force display in Outlook Address Book
Outlook.ContactItem contact = addressBook.Items.Add();
contact.FullName = "Custom Industries, Inc.";
contact.Email1Address = "sales@customindustries.com";
contact.Save();

这篇关于为Outlook 2010中创建自定义地址簿编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆