Вот функция. Когда фильтр снимаю, работает нормально. Итак, проблема в фильтре, однако я не могу найти правильное значение свойства (часть, которая выглядит так: 0x8083001F)
Я безрезультатно привязал OutlookSpy Дмитрия Стреблеченко. Число строк, указывающее количество контактов, имеющих входной адрес электронной почты, всегда равно нулю, несмотря на то, что у меня есть контакты с этим адресом электронной почты...
Надеюсь, кто-нибудь скажет мне правду. шестнадцатеричное свойство.
Код: Выделить всё
` private (int, int, int) SearchContactsInFolder(string emailAddress, Outlook.MAPIFolder Subfolder)//, BackgroundWorker worker)
{
using (Log.VerboseCall())
{
Log.VerboseFormat("Begin scanning contacts in {0}", Subfolder.Name);
if (Subfolder.DefaultItemType != Outlook.OlItemType.olContactItem)
{
string msg = $"Skipping folder {Subfolder.Name} of type {Subfolder.DefaultItemType.ToString()}";
Log.Verbose(msg);
throw new Exception(msg);
}
Outlook.Table table = null;
Outlook.Items contactItems = null;
int toCount = 0;
int ccCount = 0;
int bccCount = 0;
// 0x800F101F 0x39FE001E
//string filterTo = $"@SQL=\"http://schemas.microsoft.com/mapi/proptag/0x8083001F\" LIKE '%{emailAddress}%'";
//string filterTo = $"@SQL=\"http://schemas.microsoft.com/mapi/proptag/0x3A17001F\" = '{emailAddress}'";
string filterTo = $"@SQL=\"http://schemas.microsoft.com/mapi/proptag/0x39FE001E\" = '{emailAddress}'";
string filterCC = $"@SQL=\"http://schemas.microsoft.com/mapi/proptag/0x8093001F\" = '{emailAddress}'";
string filterBCC = $"@SQL=\"http://schemas.microsoft.com/mapi/proptag/0x80A3001F\" = '{emailAddress}'";
try
{
contactItems = Subfolder.Items;
if (contactItems != null && contactItems.Count > 0)
{
int iOutlookContacts = contactItems.Count;
Log.VerboseFormat("Number of Outlook contacts {0} folder: {1}", Subfolder.Name, iOutlookContacts.ToString());
// Count occurrences in 'To'
table = Subfolder.GetTable(filterTo, OlTableContents.olUserItems);
if (table != null)
{
toCount = table.GetRowCount();
Marshal.ReleaseComObject(table);
table = null;
}
// Count occurrences in 'CC'
table = Subfolder.GetTable(filterCC, OlTableContents.olUserItems);
if (table != null)
{
ccCount = table.GetRowCount();
Marshal.ReleaseComObject(table);
table = null;
}
// Count occurrences in 'CC'
table = Subfolder.GetTable(filterBCC, OlTableContents.olUserItems);
if (table != null)
{
bccCount = table.GetRowCount();
Marshal.ReleaseComObject(table);
table = null;
}
}
}
catch (Exception ex)
{
Log.Verbose(ex);
throw;
}
finally
{
if (contactItems != null) Marshal.ReleaseComObject(contactItems);
if (table != null) Marshal.ReleaseComObject(table);
}
return (toCount, ccCount, bccCount);
}
}`
Пробывал Outlook Spy.
Подробнее здесь: https://stackoverflow.com/questions/784 ... dasl-table