Email 在C中按显示的接收日期而不是标题信息日期搜索outlook邮件项目#
我于2013年6月25日14:52:37-0400(美国东部夏令时)收到outlook邮件 它正在显示:Email 在C中按显示的接收日期而不是标题信息日期搜索outlook邮件项目#,email,date,search,Email,Date,Search,我于2013年6月25日14:52:37-0400(美国东部夏令时)收到outlook邮件 它正在显示: Wed 6/26/2013 12:29 AM (in GMT). 现在在我的C#窗口应用程序中,当我在检查邮件时 此邮件在收到日期6月26日至6月28日之间未显示 (如果我们在收到日期6月25日至6月28日之间对其进行扫描,则显示) 我的搜索条件为 详情如下: "urn:schemas:httpmail:datereceived >= '6/26/2013' AND "urn:s
Wed 6/26/2013 12:29 AM (in GMT).
现在在我的C#窗口应用程序中,当我在检查邮件时
此邮件在收到日期6月26日至6月28日之间未显示
(如果我们在收到日期6月25日至6月28日之间对其进行扫描,则显示)
我的搜索条件为
详情如下:
"urn:schemas:httpmail:datereceived >= '6/26/2013' AND "urn:schemas:httpmail:datereceived"" <='6/28/2013'
“urn:schemas:httpmail:datereceived>='6/26/2013'和“urn:schemas:httpmail:datereceived”“我的答案在这里
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);
}
string filter=@“@SQL=(“urn:schemas:httpmail:datereceived”“>=”+datStartUTC+@”和“urn:schemas:httpmail:datereceived”“=”+datStartUTC+@“urn:schemas:httpmail:datereceived”“日期”