P
Pete Davis
I've got several things that are throwing me off and I could use some help.
I've written a plugin in C#. The plugin aspect works fine.
When I receive a new e-mail, I would like to find each new e-mail. I'm not
sure what the best way to do it is, but what I've resorted to (and I don't
like it) is to try to iterate through all the folders and find every e-mail
since the last time I checked. I then perform some stuff on each e-mail.
There are several issues here:
GetFirst and GetNext: I can't use the foreach() construct in C# because
there is no enumerator. The next thing I tried was something like this:
Outlook.MailItem mi = null;
for (int index = 0; index < folders.Items.Count; index++)
{
mi = (Outlook.MailItem) folders.Items.Item(index);
}
This, however, throws an exception, even though the items are MailItems.
I then tried this:
Outlook.MailItem mi = (Outlook.MailItem) folder.Items.GetFirst()
while (null != mi)
{
...
mi = (Outlook.MailItem) folder.Items.GetNext()
}
Except in this case, GetNext() always seems to return the first item. What's
up with that? Isn't it supposed to go to the next item?
My second problem has to do with getting the time from the messages.
If I do:
DateTime dt = mi.SentOn;
or
DateTime dt = mi.ReceivedTime;
I always get 6/20/2002 7:32:10PM
I'm real close to accomplishing what I want to do, if I can just get this
crap ironed out. Thanks.
Pete
I've written a plugin in C#. The plugin aspect works fine.
When I receive a new e-mail, I would like to find each new e-mail. I'm not
sure what the best way to do it is, but what I've resorted to (and I don't
like it) is to try to iterate through all the folders and find every e-mail
since the last time I checked. I then perform some stuff on each e-mail.
There are several issues here:
GetFirst and GetNext: I can't use the foreach() construct in C# because
there is no enumerator. The next thing I tried was something like this:
Outlook.MailItem mi = null;
for (int index = 0; index < folders.Items.Count; index++)
{
mi = (Outlook.MailItem) folders.Items.Item(index);
}
This, however, throws an exception, even though the items are MailItems.
I then tried this:
Outlook.MailItem mi = (Outlook.MailItem) folder.Items.GetFirst()
while (null != mi)
{
...
mi = (Outlook.MailItem) folder.Items.GetNext()
}
Except in this case, GetNext() always seems to return the first item. What's
up with that? Isn't it supposed to go to the next item?
My second problem has to do with getting the time from the messages.
If I do:
DateTime dt = mi.SentOn;
or
DateTime dt = mi.ReceivedTime;
I always get 6/20/2002 7:32:10PM
I'm real close to accomplishing what I want to do, if I can just get this
crap ironed out. Thanks.
Pete