C #, Lotus Interop: getting information about a message

I am using Interop.Domino.dll to retrieve emails from a Lotus database (the term is loosely used). I'm having a hard time finding some fields and wondering how to do this properly. I used NotesDocument.GetFirstItem

to extract object, from and body.

My problems in this regard are:

  • How can I get a reply to the address? Is there a list of "Items" to get somewhere? I can not find him.
  • How do I get friendly names for From and Reply addresses?
  • When I receive the Body this way, it is wierdly formatted with square brackets ([]) alternating randomly across the body of the message and parts of the text are not where I expect them to be.

Related code:

string 
  ActualSubject = nDoc.GetFirstItem("Subject").Text,
  ActualFrom = nDoc.GetFirstItem("From").Text,
  ActualBody = nDoc.GetFirstItem("Body").Text;

      

0


source to share


3 answers


Yes, I got it!

Object[] ni = (Object[])nDoc.Items;
string names_values = "";
for (int x = 0; x < ni.Length; x++)
{
NotesItem item = (NotesItem)ni[x];
if (!string.IsNullOrEmpty(item.Name)) names_values += x.ToString() + ": " + item.Name + "\t\t" + item.Text + "\r\n";
}

      

This returned a list of indices, names and values:



0: Received     from example.com ([192.168.0.1])          by host.example.com (Lotus Domino Release 6.5.4 HF182)          with ESMTP id 2008111917343129-205078 ;          Wed, 19 Nov 2008 17:34:31 -0500
1: Received     from example.com ([192.168.0.2])          by host2.example.com (Lotus Domino Release 6.5.4 HF182)          with ESMTP id 2008111917343129-205078 ;          Wed, 19 Nov 2008 17:34:31 -0500
2: X_PGRTRKID       130057945714t
3: X_PGRSRC     IE
4: ReplyTo      "example" <name@email.example.com>
5: Principal        "example" <customerservice@email.example.com>
6: From         "IE130057945714t"<service@test.email.example.com>
7: SendTo       me@example.com
8: Subject      (Message subject redacted)
9: PostedDate       11/19/2008 03:34:15 PM
10: MIME_Version        1.0
11: $Mailer     SMTP DirectMail
12: $MIMETrack      Itemize by SMTP Server on xxxPT02-CORP/example(Release 6.5.4 HF182|May 31, 2005) at 11/19/2008 05:34:31 PM;Serialize by Router on xxxPT02-CORP/example(Release 6.5.4 HF182|May 31, 2005) at 11/19/2008 05:34:32 PM;Serialize complete at 11/19/2008 05:34:32 PM;MIME-CD by Router on xxxPT02-CORP/example(Release 6.5.4 HF182|May 31, 2005) at 11/19/2008 05:34:32 PM;MIME-CD complete at 11/19/2008 05:34:32 PM;Itemize by Router on camp-db-05/example(Release 7.0.2 HF76|November 03, 2006) at 11/19/2008 05:34:32 PM;MIME-CD by Notes Client on MyName/Guest/example(Release 6.5.6|March 06, 2007) at 11/20/2008 12:46:25 PM;MIME-CD complete at 11/20/2008 12:46:25 PM
13: Form        Memo
14: $UpdatedBy      ;CN=xxxPT02-CORP/O=example
15: $ExportHeadersConverted     1
16: $MessageID      <redacted@LocalDomain>
17: RouteServers        CN=xxxPT02-CORP/O=example;CN=camp-db-05/O=example
18: RouteTimes      11/19/2008 03:34:31 PM-11/19/2008 03:34:32 PM;11/19/2008 03:34:32 PM-11/19/2008 03:34:32 PM
19: $Orig       958F2E4E4B666AB585257506007C02A7
20: Categories      
21: $Revisions      
22: DeliveredDate       11/19/2008 03:34:32 PM
23: Body        []exampleexample

      

Now who can tell me why the Body keeps going bad?

+2


source


The Body element is a NotesRichTextItem, not a regular NotesItem. They are a different type of entity in the Lotus Notes world (and often a source of developer frustration!)

I don't have much experience using COM to connect to Domino, and I know there are differences in what you have access to, but in the Domino Designer Help, you should give you a lot of information about classes like NotesRichTextItem.

Perhaps the GetFormattedText method will work better for you than accessing the Text property of the object.



Here is an example method (taken from Domino Designer help)

Dim doc As NotesDocument
Dim rtitem As Variant
Dim plainText As String
Dim fileNum As Integer
'...set value of doc...
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
  plainText = rtitem.GetFormattedText( False, 0 )
End If
' get a file number for the file
fileNum = Freefile
' open the file for writing
Open "c:\plane.txt" For Output As fileNum
' write the formatted text to the file
Print #fileNum, plainText
' close the file
Close #fileNum

      

+1


source


It might not work depending on your environment setup, but the easiest way to handle mail in dominoes is to leave them as MIME and get the values โ€‹โ€‹through NotesMIMEEntity and NotesMIMEHeader. This will only work if the mail comes from the Internet and not from native Notes and the environment has been configured to store mail in MIME format.

Otherwise, you need to access the body as a NotesRichTextItem. From this point you need to get the NotesRichTextNavigator, which will allow you to navigate the texture structure if you need to.

If you think struture should be relatively simple, try calling NotesRichTextItem.GetFormattedText (). If that doesn't work yet, you will need to decide what happeing is by playing around with the doument example and seeing what the structure looks like in the NotesRichTextNavigator.

0


source







All Articles