Hi Peter,
I did not figure what do you mean very well.
Do you mean you wants to get the items in the Contact Folder in the Outlook
or the recipient of a MailMessage?
Here is some code that will automation outlook to Enumerate the Contact Box
or Enumerate the recipients in a sentmail.
using System;
using Outlook = Microsoft.Offic e.Interop.Outlo ok;
namespace AutoOutLook
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
//Enumerate the Contact Box
Outlook.Applica tion olApp = new Outlook.Applica tionClass();
Outlook.MAPIFol der mf =
olApp.GetNamesp ace("MAPI").Get DefaultFolder(O utlook.OlDefaul tFolders.olFold e
rContacts);
foreach(object ci in mf.Items)
{
if (ci as Outlook.Contact Item != null)
Console.WriteLi ne(((Outlook.Co ntactItem)ci).F ullName);
}
//Enumerate the recipients in a sentmail
Outlook.MAPIFol der mf2 =
olApp.GetNamesp ace("MAPI").Get DefaultFolder(O utlook.OlDefaul tFolders.olFold e
rSentMail);
Console.WriteLi ne(mf2.Items.Co unt);
Outlook.MailIte m mi = (Outlook.MailIt em)mf2.Items.Ge tFirst();
foreach (object recip in mi.Recipients)
{
if (recip as Outlook.Recipie nt != null)
Console.WriteLi ne(((Outlook.Re cipient)recip). Name);
}
}
}
}
If I misunderstandin g you meaning, can you describe what do you mean more
detailed and what do you want to do detailed?
I will appreciate your efforts.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.