How do I get recipients and attachments with the COM API?

I am trying to add Lotus Notes support to an application that I am working on.  Using the COM Toolkit's sample VBReadMail as a reference, I can extract the Subject, Body, and Sender from emails.  However, I am having a bear of a time extracting the Recipient list and the Attachment list.  Many of the examples I find use script languages like Lotus Script and VB.  I am using C#.

Can anyone provide some pointers?  Is there any good reference books or sites that can guide me?  I am only beginning this work and I find myself spinning my wheels a lot.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

how do you extract the Subject, Body, and Sender? recipients are stored in the SendTo, CopyTo and  BlindCopyto fields. note that these fields may contain more then 1 value. on the other hand, the names of attachement can be extracted from the $File field(s) or body field.  

would you consider using Notes COM objects? could you post your code here?
jlalandeAuthor Commented:
I am using the Notes COM objects.  I believe I mentioned that.  And you are correct; the recipients can be retrieved in the same way as the subject and the body.  However, when I try the $File field, I am getting weird results.  All the emails I am extracting were sent by Outlook so the behaviour may be related to that.  But what I see is any email that was a reply has a file called winmail.dat.  A test email that I sent to myself (using Outlook) with a text file attached only has a file called winmail.dat.  Where an email that has two MSWord attachments, notesDocument.GetItemValue("$File") as Array returns an array of one element which correctly contains the name of one of the attachments.
sorry, could have missed the "Using the COM Toolkit's sample VBReadMail".

Outlook could be using the winmail.dat file for outlook clients. The mail will contain more than one $file field if more than one attachement is present. try to use the GetEmbeddedObject method of the NotesRichTextItem class to loop thru all embedded objects in the body of the email.

hope this helps
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Sjef BosmanGroupware ConsultantCommented:
The other day, I read something about Winmail.dat, that its production is actually caused by some setting in Outlook. I can't find the question at EE anymore. Here's an older topic about this:
    http:Q_21420573.html "receive attachments as winmail.dat"
jlalandeAuthor Commented:
Because GetEmbeddedObject requires the name of the embedded object, I assume that I get the names by getting the values of the multiple $FILE fields.  But how do you get them?  Calling GetItemVlaue multiple times isn't the answer...I tried that.

use something like this to loop thru the embedded objects in the body of the email.  note that o is of type NotesEmbeddedObject. you can use other properties(like size...) or methods (like ExtractFile..)  

Dim doc As NotesDocument
Dim rtitem As Variant
'...set value of doc...
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
  Forall o In rtitem.EmbeddedObjects
    If ( o.Type = EMBED_ATTACHMENT ) Then
        msgbox o.Name
    End If
  End Forall
End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jlalandeAuthor Commented:
With a little massaging and some research, I used your vb code to generate this solution in c#.

            NotesRichTextItem rti = item.GetFirstItem("Body") as NotesRichTextItem;
            Array attachments = rti.EmbeddedObjects as Array;
            ArrayList attsList = new ArrayList();
            foreach (NotesEmbeddedObject neo in attachments)
               if (neo.type == EMBED_TYPE.EMBED_ATTACHMENT)
                  attsList.Add(new Attachment(neo));

Thanks for your help!

thanks for the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.