Retrieving Mail Information

D

DMc2004

How can I retrieve information such as Sender, Recipient, Subject, Sent Date,
Mail Size from the Inbox of Microsoft Office Outlook 2003?

Regards

D
 
K

Ken Slovak - [MVP - Outlook]

Use ActiveExplorer.CurrentFolder.Items to get the collection of items in the
folder (if the Inbox is currently being displayed). Otherwise use
NameSpace.GetDefaultFolder(olFolderInbox).Items to get that collection.

Iterate the collection and retrieve whatever properties you want from each
item. Make sure to test for item.Class = olMail if you are only interested
in mail items.
 
T

Tom Hamilton

Hi Ken,
I'm having problem following the suggestion you offer. I'm converting an
Outlook 2003 add-in that I prototyped in vb using VS2005. The problem is
identifying the currently selected mail item.

in vb I was using :
Dim selItem As Outlook.MailItem = _Explorer.Selection(1)

I converted to C# as:
Outlook.MailItem selItem = _Explorer.Selection(1);

But it will not compile -
I'd really like to iterate through all selected emails but right now I just
need to get the currently selected one.

Thanks
--
Tom Hamilton
Hamilton & Hamilton
Database Consulting Services
Sacramento, CA
 
T

Tom Hamilton

Never mind - C# indexes with [] which is why () didn't work....

What's the best way to Loop thru Selection?
--
Tom Hamilton
Hamilton & Hamilton
Database Consulting Services
Sacramento, CA
 
K

Ken Slovak - [MVP - Outlook]

It depends on what you're doing inside the loop and what sort of objects
you're dealing with.

For deleting or moving items in a loop you should use a down counting loop
so changes to the collection's count don't mess with the loop indexing. So a
for loop that starts at Selection.Count (use an int variable to pick that up
and don't use Selection.Count in the loop) and works down to 1 would work. A
do loop can also be used that checks for a Selection.Count of 0.

For anything else you can use any sort of loop construct you're most
comfortable with. That can be a for loop, do loop, foreach loop or whatever.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top