T
tedy
Hello,
I`m having the following problem. I try to find out all unread
messages in the Inbox Folder,
save some of them and then mark them as read (Unread = false). First I
get with Restrict method only the unread messages. When I check some
message with Unread = false, I suppose that the items list is getting
confused and "GetNext()" never gets to the end of the list.The while
loop iterates only through about the half items.Is it the problem that
the items object is changed immediately when message unread flag is
marked (and then contains fewer messages) and how could be this
problem solved ?
Outlook.Items items = olInboxFolder.Items.Restrict(
"[MessageClass] = 'IPM.Note' and [Unread] = true");
String subject = null;
Console.WriteLine(items.Count);
Outlook.MailItem mi = (Outlook.MailItem) items.GetFirst();
Outlook.Items unread = new Outlook.Items();
while(mi != null)
{
subject = mi.Subject;
if(subjPattern.IsMatch(mi.Subject) &&
sendPattern.IsMatch(mi.SenderName))
{ subject = subject.Replace('/','_');
mi.SaveAs(path + subject + ".txt",
Outlook.OlSaveAsType.olTXT);
mi.UnRead = false; // !!!!
Console.WriteLine(mi.Subject);
}
mi = (Outlook.MailItem) items.GetNext();
}
I`m having the following problem. I try to find out all unread
messages in the Inbox Folder,
save some of them and then mark them as read (Unread = false). First I
get with Restrict method only the unread messages. When I check some
message with Unread = false, I suppose that the items list is getting
confused and "GetNext()" never gets to the end of the list.The while
loop iterates only through about the half items.Is it the problem that
the items object is changed immediately when message unread flag is
marked (and then contains fewer messages) and how could be this
problem solved ?
Outlook.Items items = olInboxFolder.Items.Restrict(
"[MessageClass] = 'IPM.Note' and [Unread] = true");
String subject = null;
Console.WriteLine(items.Count);
Outlook.MailItem mi = (Outlook.MailItem) items.GetFirst();
Outlook.Items unread = new Outlook.Items();
while(mi != null)
{
subject = mi.Subject;
if(subjPattern.IsMatch(mi.Subject) &&
sendPattern.IsMatch(mi.SenderName))
{ subject = subject.Replace('/','_');
mi.SaveAs(path + subject + ".txt",
Outlook.OlSaveAsType.olTXT);
mi.UnRead = false; // !!!!
Console.WriteLine(mi.Subject);
}
mi = (Outlook.MailItem) items.GetNext();
}