问题描述
我正在尝试获取 Outlook 中特定文件夹内的电子邮件的正文(或任何其他属性).
I'm trying to get the body(or any other attribute) of an email which is inside a specific folder in outlook.
我正在使用 interop.outlook
程序集.到目前为止,我已经完成了以下工作.但是当尝试调用 myInbox
中的项目时,根本没有属性.
I'm using the interop.outlook
assembly.I have done the following so far. But when trying to call an item in myInbox
, there are no attributes at all.
Application myApp = new ApplicationClass();
NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders["QC"];
以下没有带来预期的属性
The following brings no expected attributes
myInbox.Items[1].
此外,下一步是单击电子邮件正文中的链接.只是想知道这是否可能.
In addition, the next step is to click a link inside the body of the email. just want to know if it's even possible.
任何帮助将不胜感激.
推荐答案
这就是我的做法;
Outlook.Application myApp = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Folders["QC"];
这应该会将所有邮件带入收件箱.然后调用;
This should bring all mails in Inbox. Then call;
Outlook.MailItem mailItem = myInbox.Items[1];
此mailItem
包含您需要的所有属性.
This mailItem
contains all the attributes you need.
说明:mailFolder.Items[1]
是一个 Outlook.Items
对象,它没有您需要的属性.您需要将其转换为 Outlook.MailItem
对象以实现此目的.
Explanation: The mailFolder.Items[1]
is an Outlook.Items
object which has no attributes you require. You need to cast it to an Outlook.MailItem
object to achieve this.
这篇关于Interop.Outlook - 获取子文件夹中的所有电子邮件(项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!