代码之家  ›  专栏  ›  技术社区  ›  tsilb

C,LotusInterop:获取消息信息

  •  0
  • tsilb  · 技术社区  · 16 年前

    我在用 Interop.Domino.dll 从Lotus“数据库”中检索电子邮件(这是一个松散使用的术语)。我在检索某些字段时遇到了一些困难,我想知道如何正确地执行此操作。我一直在使用 NotesDocument.GetFirstItem 从和身体中检索主题。

    因此,我在这方面的问题是:

    1. 如何检索答复地址?是否有“项目”列表可供选择?我找不到。
    2. 如何从地址中检索友好名称并答复地址?
    3. 当我以这种方式检索正文时,它的格式是wierdly,其中方括号集([])随机分布在消息正文中,而文本的某些部分并不是我所期望的。

    相关代码:

    string 
      ActualSubject = nDoc.GetFirstItem("Subject").Text,
      ActualFrom = nDoc.GetFirstItem("From").Text,
      ActualBody = nDoc.GetFirstItem("Body").Text;
    
    3 回复  |  直到 9 年前
        1
  •  2
  •   tsilb    16 年前

    哈,明白了!

    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";
    }
    

    这将返回索引、名称和值的列表:

    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
    

    现在,谁能告诉我为什么尸体总是乱七八糟的?

        2
  •  1
  •   Ken Pespisa    16 年前

    正文项是notesrichtextitem,而不是常规的notesitem。它们是LotusNotes世界中的一种不同类型的对象(通常也是开发人员感到沮丧的原因!)

    我对使用COM连接到Domino没有太多的经验,我知道在您可以访问的内容方面存在差异,但是Domino Designer帮助应该为您提供大量的类信息,例如notesrichtextitem。

    也许方法“getFormattedText”比访问项的文本属性更适合您。

    下面是该方法的一个示例(摘自DominoDesigner帮助)

    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
    
        3
  •  0
  •   Kerr    16 年前

    它可能不起作用,这取决于您的环境是如何设置的,但是在Domino中处理邮件的最简单方法是将它们保留为mime,并通过notesmimeetity和notesmimeheader获取值。只有当邮件来自Web而不是本机Notes,并且环境设置为以mime格式存储邮件时,此操作才有效。

    否则,您需要以notesrichtextitem的形式访问主体。从该项目中,您需要获得一个notesrichtextnavigator,如果需要,它将允许您围绕富文本结构移动。

    如果您认为结构应该相对简单,请尝试调用notesrichtextitem.getFormattedtext()。如果这仍然不起作用,那么您需要通过使用一个示例doumen并查看notesrichtextnavigator的结构是什么来计算出发生了什么。

    推荐文章