Code: Select all
var spams = GetMessagesFromList();
foreach(long l in spams)
{
try
{
Console.WriteLine("Processing Spam:" + l);
var msg = inboxFolder.Messages.ItemByDBID[l];
var theMessage = new Message(msg);
messages.Add(theMessage);
}
catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
the spams list in this test is just reading from a text file that contains a single number..
I am setting this number manually to test -
This is a db item I am trying to target:
I have tried specifying both 815980 and 4126:
To match this row in the db
messageid messageaccountid messagefolderid messagefilename messagetype messagefrom messagesize messagecurnooftries messagenexttrytime messageflags messagecreatetime messagelocked messageuid
815980 4006 12039 {1148D25C-29A1-4938-988D-960CC282E93B}.eml 2 *****@0337.com 3228 0 1901-01-01 00:00:00.000 32 2020-11-09 08:44:38.000 0 4126
But no matter which one I specify to the inboxFolder.Messages.ItemByDBID[l]; object, I receive 'Invalid Index' COM Exception.
I have also tried inboxFolder.Messages[] specifying the l variable in there...
That also throws an Invalid Index exception.
The only way I have of accessing messages is to loop from 0 - > Count-1 of messages and grab them one by one.
Any idea whats going on here?