以编程方式为 Outlook 2010 创建自定义通讯簿 [英] Create a custom address book for Outlook 2010 programmatically

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

问题描述

我想创建一个自定义联系人列表(或称为地址簿),以便用户在 Outlook 中查看建议的联系人",联系人"等,然后是自定义联系人".我去尝试了以下方法.

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;

这给了我 8 的值.所以,很自然地,我已经尝试向地址列表对象Add 一些东西,但你猜怎么着 - 没有这样的方法.这并不奇怪,因为 API 明确指出它是只读对象.但是,我需要为我的客户设置一个地址簿/列表(不管它叫什么).

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.

如何向 Outlook 添加新的地址簿?

How do I add a new Address Book to Outlook?

推荐答案

您可以使用以下代码创建 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天全站免登陆