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.
jlalandeAsked:
Who is Participating?
 
cezarFCommented:
jlalande,

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
0
 
cezarFCommented:
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?
0
 
jlalandeAuthor Commented:
cezarF
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.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
cezarFCommented:
jlalande,
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
0
 
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"
0
 
jlalandeAuthor Commented:
cezarF
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.
0
 
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!
0
 
cezarFCommented:
great!

thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.