通过显示的接收日期而不是C#中的标题信息日期来搜索Outlook邮件项目 [英] search outlook mail Item by displayed received date instead of Header Information Date in C#
本文介绍了通过显示的接收日期而不是C#中的标题信息日期来搜索Outlook邮件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在2013年6月25日14:52:37 -0400(EDT)
上收到了一封Outlook邮件,它显示:
I have received an outlook mail at 25 Jun 2013 14:52:37 -0400 (EDT) and it is displaying:
Wed 6/26/2013 12:29 AM (in GMT).
当我搜索邮件项目时,现在在C#窗口应用程序中
Now in my C# window application when i am seraching mail item
此邮件在接收日期6月26日至6月28日之间不显示
(如果我们在接收日期6月25日至6月28日之间进行搜索,则显示)
我在$中的搜索条件b $ b如下:
this mail is not displaying between received date 26 June to 28 June (if we are seraching it between received date 25 June to 28 June it is displaying ) my search condition in as follows:
"urn:schemas:httpmail:datereceived >= '6/26/2013' AND "urn:schemas:httpmail:datereceived"" <='6/28/2013'
如何将我的搜索应用于显示的日期和时间而不是标题信息中的信息?
How to apply my search on Displayed date and time instead of Information in Header information?
推荐答案
我的答案在这里
using OutLook = Microsoft.Office.Interop.Outlook;
OutLook.Application outlookObj;
OutLook.NameSpace olintNS;
OutLook.MailItem mailitem;
mailitem = outlookObj.CreateItem(OutLook.OlItemType.olMailItem);
OutLook.PropertyAccessor pa = mailitem.PropertyAccessor;
DateTime datStartUTC = pa.LocalTimeToUTC(Convert.ToDateTime("6/26/2013"));
DateTime datEndUTC =pa.LocalTimeToUTC(Convert.ToDateTime("6/28/2013").AddDays(1));
//我的搜索条件
string filter = @"@SQL=((""urn:schemas:httpmail:datereceived"" >= '" + datStartUTC + @"' AND ""urn:schemas:httpmail:datereceived"" <='" + datEndUTC + @"' ) OR (""urn:schemas:httpmail:date"" >= '" + datStartUTC + @"' AND ""urn:schemas:httpmail:date"" <='" + datEndUTC + @"' ) ) ";
OutLook.Items items = oFolder.Items.Restrict(filter);
// Now I can Put searched item in to My DataTable
foreach (OutLook.MailItem mail in items)
{
DataRow dr = dtInbox.NewRow();
dr["TO"] = mail.To;
dr["From"] = mail.SenderEmailAddress;
dr["Subject"] = mail.Subject;
dr["EntryID"] = mail.EntryID;
dr["folderStoreID"] = oFolder.StoreID; dr["Date"] = mail.ReceivedTime;//? (mail.SentOn != null ? mail.SentOn.ToString("MM/dd/yyyy") : "") : (mail.ReceivedTime); dtInbox.Rows.Add(dr);
}
这篇关于通过显示的接收日期而不是C#中的标题信息日期来搜索Outlook邮件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文