切换到宽版
Exchange 中文站
Exchange 2003
Exchange 2007
Exchange 2010
Exchange 2013
勋章中心
下拉
用户名
电子邮箱
用户名
密 码
记住登录
登录
找回密码
注册
快捷通道
关闭
您还没有登录,快捷通道只有在登录后才能使用。
立即登录
还没有帐号? 赶紧
注册一个
Exchange论坛
Exchange视频
Exchange技术论坛
>
Exchange 二次开发
>
Exchange Server 2007 二次开发 (五)
发帖
回复
返回列表
10348
阅读
2
回复
[分享]
Exchange Server 2007 二次开发 (五)
[复制链接]
上一主题
下一主题
tata
UID:10027
注册时间
2010-11-12
最后登录
2015-11-13
在线时间
866小时
发帖
363
搜Ta的帖子
精华
0
金币
186
访问TA的空间
加好友
用道具
初级工程师
关闭
个人中心可以申请新版勋章哦
立即申请
知道了
加关注
发消息
只看楼主
倒序阅读
0楼
发表于: 2011-02-19
创建联系人,这段代码来自SDK:
1
public
static
void
CreateContact(ExchangeServiceBinding esb)
2
{
3
//
Create an object of create item type.
4
CreateItemType createItemType
=
new
CreateItemType();
5
6
//
Because you are creating a contact, save the item in the Contacts folder.
7
createItemType.SavedItemFolderId
=
new
TargetFolderIdType();
8
DistinguishedFolderIdType contactsFolder
=
new
DistinguishedFolderIdType();
9
contactsFolder.Id
=
DistinguishedFolderIdNameType.contacts;
10
11
createItemType.SavedItemFolderId.Item
=
contactsFolder;
12
13
createItemType.Items
=
new
NonEmptyArrayOfAllItemsType();
14
createItemType.Items.Items
=
new
ItemType[
1
];
15
16
//
Create a contact item type.
17
ContactItemType contactItem
=
new
ContactItemType();
18
19
//
Set the relevant properties on the contact.
20
contactItem.FileAs
=
"
Friend A
"
;
21
22
//
Set the contact name and job information.
23
contactItem.GivenName
=
"
Don
"
;
24
contactItem.Surname
=
"
Hall
"
;
25
contactItem.CompanyName
=
"
AdventureWorks
"
;
26
contactItem.JobTitle
=
"
Software Engineer
"
;
27
28
//
Set a single e-mail address for the contact.
29
contactItem.EmailAddresses
=
new
EmailAddressDictionaryEntryType[
1
];
30
EmailAddressDictionaryEntryType address
=
new
EmailAddressDictionaryEntryType();
31
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] address.Key
=
EmailAddressKeyType.EmailAddress1;
32
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] address.Value
=
"
don@example.com
"
;
33
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] contactItem.EmailAddresses[
0
]
=
address;
34
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
35
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
Set a single contact physical address.
36
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
contactItem.PhysicalAddresses
=
new
PhysicalAddressDictionaryEntryType[
1
];
37
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] PhysicalAddressDictionaryEntryType physicalAddress
=
new
PhysicalAddressDictionaryEntryType();
38
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] physicalAddress.Key
=
PhysicalAddressKeyType.Home;
39
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] physicalAddress.Street
=
"
1234 56 Ave NE
"
;
40
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] physicalAddress.City
=
"
La Habra Heights
"
;
41
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] physicalAddress.CountryOrRegion
=
"
United States
"
;
42
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] physicalAddress.PostalCode
=
"
98072
"
;
43
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
44
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] contactItem.PhysicalAddresses[
0
]
=
physicalAddress;
45
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
46
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
Set the contact telephone number.
47
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
contactItem.PhoneNumbers
=
new
PhoneNumberDictionaryEntryType[
1
];
48
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] PhoneNumberDictionaryEntryType phoneEntry
=
new
PhoneNumberDictionaryEntryType();
49
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] phoneEntry.Key
=
PhoneNumberKeyType.BusinessPhone;
50
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] phoneEntry.Value
=
"
5625550100
"
;
51
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
52
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] contactItem.PhoneNumbers[
0
]
=
phoneEntry;
53
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
54
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] createItemType.Items.Items[
0
]
=
contactItem;
55
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
56
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
Send the request to create the contact item; receive the response.
57
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
CreateItemResponseType createItemResponse
=
esb.CreateItem(createItemType);
58
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
59
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
Check the results of the request.
60
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
if
(createItemResponse.ResponseMessages.Items.Length
>
0
&&
61
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] createItemResponse.ResponseMessages.Items[
0
].ResponseClass
==
ResponseClassType.Success)
62
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif[/img]
{
63
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] ItemInfoResponseMessageType responseMessage
=
createItemResponse.ResponseMessages.Items[
0
]
as
ItemInfoResponseMessageType;
64
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] ContactItemType contactResponse
=
responseMessage.Items.Items[
0
]
as
ContactItemType;
65
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] Console.WriteLine(
"
Created Contact Item with Id {0} and ChangeKey {1}
"
, contactResponse.ItemId.Id, contactResponse.ItemId.ChangeKey);
66
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif[/img] }
67
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif[/img] }
共
条评分
回复
举报
分享到
script
UID:11734
注册时间
2011-03-09
最后登录
2015-02-02
在线时间
37小时
发帖
89
搜Ta的帖子
精华
0
金币
170
访问TA的空间
加好友
用道具
技术人员
加关注
发消息
只看该作者
1楼
发表于: 2011-03-09
Exchange Server 2007 二次开发是非常重要的。我要好好的学习。
共
条评分
回复
举报
asd135521591
UID:19412
注册时间
2013-02-20
最后登录
2013-02-20
在线时间
0小时
发帖
11
搜Ta的帖子
精华
0
金币
23
访问TA的空间
加好友
用道具
技术学徒
加关注
发消息
只看该作者
2楼
发表于: 2013-02-20
共
条评分
回复
举报
发帖
回复
返回列表
http://bbs.exchangecn.com
访问内容超出本站范围,不能确定是否安全
继续访问
取消访问
快速回复
限60 字节
您目前还是游客,请
登录
或
注册
进入高级模式
文字颜色
发 布
回复后跳转到最后一页
上一个
下一个
关闭
补充发布信息
验证码:
验证问题:
96 - 36 = ?
发 布
隐藏
快速跳转
Microsoft 企业云服务
Office 365 定制版用户讨论区
Exchange 技术讨论
Exchange Server 2016
Exchange Server 2013
Exchange Server 2010
Exchange Server 2007
Exchange Server 2003
Exchange 相关技术
Exchange 事件日志
Exchange 二次开发
Microsoft Outlook
Exchange 资源下载
Exchange 2003 资源下载
Exchange 2007 资源下载
Exchange 2010 资源下载
Exchange 招聘求职
Exchange 招聘 | 求职
Exchange 社区站务
站内站务
关闭
关闭
选中
1
篇
全选