?
Solved

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

Posted on 2006-04-24
8
Medium Priority
?
367 Views
Last Modified: 2013-12-18
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.
0
Comment
Question by:jlalande
  • 4
  • 3
8 Comments
 
LVL 14

Expert Comment

by:cezarF
ID: 16531842
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
 

Author Comment

by:jlalande
ID: 16536158
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
 
LVL 14

Expert Comment

by:cezarF
ID: 16540140
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16541704
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
 

Author Comment

by:jlalande
ID: 16581645
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
 
LVL 14

Accepted Solution

by:
cezarF earned 2000 total points
ID: 16582525
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
 

Author Comment

by:jlalande
ID: 16588402
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
 
LVL 14

Expert Comment

by:cezarF
ID: 16592299
great!

thanks for the points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question