问题描述
我有一个网格,我从Exchange Server加载了Mai信息
使用下面代码
I have one grid that grid I loaded Mai information from Exchange Server
using Below code
Private Sub LoadInbox()
{
ExchangeService _service = new ExchangeService(ExchangeVersion.Exchange2010);
_service.Credentials = new WebCredentials("userName", "password");
_service.AutodiscoverUrl("Email ID");
FindItemsResults<Item> findResults = _service.FindItems(WellKnownFolderName.Inbox, view);;
DataRow drrow;
if (findResults.Items.Count > 0)
{
dtInbox.Rows.Clear();
foreach (Item myItem in findResults.Items)
{
if (myItem is EmailMessage)
{
myItem.Load();
drrow = dtInbox.NewRow();
drrow["ID"] = (myItem as EmailMessage).Id;
drrow["Size"] = (myItem as EmailMessage).Size+ " kb";
drrow["Subject"] = (myItem as EmailMessage).Subject;
drrow["From"] = (myItem as EmailMessage).From;
drrow["ReceivedDate"] = (myItem as EmailMessage).DateTimeReceived;
drrow["Body"] = (myItem as EmailMessage).Body;
dtInbox.Rows.Add(drrow);
}
}
datagridview.datasource=dtInbox;
}
}
dtInbox数据表
i分箱到电网控制
我的要求
当用户点击gridview时,我会收到消息ID
表示 drrow [ID] =(myItem as EmailMessage).Id
使用该ID我需要选择邮件信息从Exchange Server
示例(主题,附件,cc MailID Bc邮件ID等.....)
我怎样才能做到这一点帮助我.........
dtInbox data table
i binned to grid control
My requirement
When the user Click on gridview I will get Message Id
that means drrow["ID"] = (myItem as EmailMessage).Id
using that ID I Need to select Mail information From the Exchange Server
Example (subject,attachment,cc MailID Bc Mail ID etc.....)
How can i do this any one Help me.........
推荐答案
Item i = Item.Bind(_service, messageId);
if (i is EmailMessage)
{
return (EmailMessage)i;
}
然后您可以访问电子邮件的属性。这是因为在使用FindItems()方法时,您只获得可用详细信息的一小部分,因此您需要返回服务以获取特定消息以获取所有详细信息。
Then you can access the properties of the e-mail. This is because when using the FindItems() method you are getting only a small subset of the details available, so you need to go back to the service to get a specific message to get all the details.
这篇关于如何从Exchange Server获取邮件信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!