通过具有特定主题的Outlook电子邮件进行迭代

时间:2016-04-18 09:05:16

标签: c# outlook

我目前正在处理method下面的Inbox,它会在我的filter中回复电子邮件,但想知道如何static subject他们专注于那些nice weather的人,例如:folders.Items.Restrict()。我认为condition is not valid可以帮助我进行搜索,但我var fi = folder.Items.Restric("weather")var fi = folder.Items.Find("[Subject] = weather")static void IterateMessages(Outlook.Folder folder) { string[] extensionsArray = {".csv"}; //var fi = folder.Items; var fi = folder.Items.Restrict("weather"); if (fi != null) { foreach (Object item in fi) { Outlook.MailItem mi = (Outlook.MailItem)item; var attachments = mi.Attachments; if (attachments.Count != 0) { if (!Directory.Exists(basePath) { Directory.CreateDirectory(basePath); } // Loop through each attachment for (int i = 1; i <= mi.Attachments.Count; i++) { Console.WriteLine("Processing: {0}", mi.Attachments[i].FileName); mi.Attachments[i].SaveAsFile(basePath); Console.WriteLine("Attachment: {0}" + " Saved to Path", mi.Attachments[i].FileName); } } } } } 。我也试过了 JRE_HOME,以确保条件有效,......但最终没有任何改进。

提前致谢

 [exec] The JRE_HOME environment variable is not defined correctly
 [exec] This environment variable is needed to run this program
 [exec] Result: 1

1 个答案:

答案 0 :(得分:3)

您的Restrict参数似乎格式错误。试试这个:

var fi = folder.Items.Restrict("@SQL=\"urn:schemas:httpmail:subject\" like '%weather%'";

More information