切换到宽版
Exchange 中文站
Exchange 2003
Exchange 2007
Exchange 2010
Exchange 2013
勋章中心
下拉
用户名
电子邮箱
用户名
密 码
记住登录
登录
找回密码
注册
快捷通道
关闭
您还没有登录,快捷通道只有在登录后才能使用。
立即登录
还没有帐号? 赶紧
注册一个
Exchange论坛
Exchange视频
Exchange技术论坛
>
Exchange 二次开发
>
Exchange Server 2007 二次开发 (七)
发帖
回复
返回列表
8754
阅读
1
回复
[分享]
Exchange Server 2007 二次开发 (七)
[复制链接]
上一主题
下一主题
tata
UID:10027
注册时间
2010-11-12
最后登录
2015-11-13
在线时间
866小时
发帖
363
搜Ta的帖子
精华
0
金币
186
访问TA的空间
加好友
用道具
初级工程师
关闭
个人中心可以申请新版勋章哦
立即申请
知道了
加关注
发消息
只看楼主
倒序阅读
0楼
发表于: 2011-02-19
关键词:
服务器
exchange
获取收件箱中邮件,有两种方式,GetItemType和FindItemType,通过FindItemType只能得到邮件的一部分属性,如标题、正文、发件人姓名等等,而像发件人地址、会议邀请邮件的会议地点、开始时间结束时间等只能通过GetItemType来获得,GetItemType能得到邮件的所有属性:
1
读取会议邮件
2
public
static
void
GetMeetingMailMessage(ExchangeServiceBinding exchangeServer)
3
{
4
DistinguishedFolderIdType[] folderIDArray
=
new
DistinguishedFolderIdType[
1
];
5
folderIDArray[
0
]
=
new
DistinguishedFolderIdType();
6
folderIDArray[
0
].Id
=
DistinguishedFolderIdNameType.inbox;
7
8
PathToUnindexedFieldType ptuftDisplayName
=
new
PathToUnindexedFieldType();
9
ptuftDisplayName.FieldURI
=
UnindexedFieldURIType.folderDisplayName;
10
11
PathToExtendedFieldType pteftComment
=
new
PathToExtendedFieldType();
12
pteftComment.PropertyTag
=
"
0x3004
"
;
//
PR_COMMENT
13
pteftComment.PropertyType
=
MapiPropertyTypeType.String;
14
15
GetFolderType myfoldertype
=
new
GetFolderType();
16
myfoldertype.FolderIds
=
folderIDArray;
17
myfoldertype.FolderShape
=
new
FolderResponseShapeType();
18
myfoldertype.FolderShape.BaseShape
=
DefaultShapeNamesType.IdOnly;
19
myfoldertype.FolderShape.AdditionalProperties
=
new
BasePathToElementType[
2
];
20
myfoldertype.FolderShape.AdditionalProperties[
0
]
=
ptuftDisplayName;
21
myfoldertype.FolderShape.AdditionalProperties[
1
]
=
pteftComment;
22
23
GetFolderResponseType myFolder
=
exchangeServer.GetFolder(myfoldertype);
24
25
26
FolderInfoResponseMessageType firmtInbox
=
27
(FolderInfoResponseMessageType)myFolder.ResponseMessages.Items[
0
];
28
29
PathToUnindexedFieldType ptuftSubject
=
new
PathToUnindexedFieldType();
30
ptuftSubject.FieldURI
=
UnindexedFieldURIType.itemSubject;
31
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
32
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] PathToUnindexedFieldType ptuftBody
=
new
PathToUnindexedFieldType();
33
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] ptuftBody.FieldURI
=
UnindexedFieldURIType.itemAttachments;
34
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
35
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] PathToExtendedFieldType pteftFlagStatus
=
new
PathToExtendedFieldType();
36
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] pteftFlagStatus.PropertyTag
=
"
0x1090
"
;
//
PR_FLAG_STATUS
37
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
pteftFlagStatus.PropertyType
=
MapiPropertyTypeType.Integer;
38
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
39
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
40
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] FindItemType findItemRequest
=
new
FindItemType();
41
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] findItemRequest.Traversal
=
ItemQueryTraversalType.Shallow;
42
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] findItemRequest.ItemShape
=
new
ItemResponseShapeType();
43
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] findItemRequest.ItemShape.BaseShape
=
DefaultShapeNamesType.AllProperties;
44
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
45
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
46
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] findItemRequest.ParentFolderIds
=
new
FolderIdType[
1
];
47
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] findItemRequest.ParentFolderIds[
0
]
=
firmtInbox.Folders[
0
].FolderId;
48
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
49
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
获取邮件
50
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
FindItemResponseType firt
=
exchangeServer.FindItem(findItemRequest);
51
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
52
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
循环迭代每一封邮件
53
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
54
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
foreach
(FindItemResponseMessageType firmtMessage
in
firt.ResponseMessages.Items)
55
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif[/img]
{
56
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
如果包含邮件,显示出来
57
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
if
(firmtMessage.RootFolder.TotalItemsInView
>
0
)
58
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif[/img]
{
59
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
循环迭代每一封邮件详细信息
60
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
foreach
(ItemType it
in
((ArrayOfRealItemsType)firmtMessage.RootFolder.Item).Items)
61
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif[/img]
{
62
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
会议邀请邮件
63
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
if
(it.ItemClass
==
"
IPM.Schedule.Meeting.Request
"
)
64
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif[/img]
{
65
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
通过GetItemType对象来得到邮件的正文
66
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
GetItemType getItemRequest
=
new
GetItemType();
67
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
设置必要的属性
68
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
getItemRequest.ItemIds
=
new
BaseItemIdType[
1
];
69
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] getItemRequest.ItemIds[
0
]
=
(BaseItemIdType)it.ItemId;
70
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] getItemRequest.ItemShape
=
new
ItemResponseShapeType();
71
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] getItemRequest.ItemShape.BaseShape
=
DefaultShapeNamesType.AllProperties;
72
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] getItemRequest.ItemShape.IncludeMimeContent
=
true
;
73
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
74
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
获得
服务器
的相应
75
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
GetItemResponseType getItemResponse
=
exchangeServer.GetItem(getItemRequest);
76
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
77
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
//
得到邮件体
78
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
ItemInfoResponseMessageType getItemResponseMessage
=
79
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] getItemResponse.ResponseMessages.Items[
0
]
as
80
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] ItemInfoResponseMessageType;
81
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
82
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] Mail.ews.MeetingRequestMessageType meeting
=
getItemResponseMessage.Items.Items[
0
]
as
Mail.ews.MeetingRequestMessageType;
83
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img]
84
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] Console.WriteLine(meeting.Subject);
85
[img]http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif[/img] Console.WriteLine(meeting.From.Item.EmailAddress);
86
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif[/img] }
87
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif[/img] }
88
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif[/img] }
89
[img]http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif[/img] }
90
[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
这些章节对我来讲真是非常有用啊。
共
条评分
回复
举报
发帖
回复
返回列表
http://bbs.exchangecn.com
访问内容超出本站范围,不能确定是否安全
继续访问
取消访问
快速回复
限60 字节
您目前还是游客,请
登录
或
注册
进入高级模式
文字颜色
发 布
回复后跳转到最后一页
上一个
下一个
关闭
补充发布信息
验证码:
验证问题:
67 + 2 = ?
发 布
隐藏
快速跳转
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
篇
全选