2008-11-20 83 views
0

我正在使用Interop.Domino.dll從蓮花「數據庫」(術語鬆散地使用)中檢索電子郵件。我在回收某些領域方面遇到了一些困難,並想知道如何正確地做到這一點。我一直在使用NotesDocument.GetFirstItem來檢索Subject,From和Body。C#,Lotus Interop:獲取消息信息

我在這方面的問題,因此:

  1. 如何取回回覆地址?是否有一個「項目」的列表去某個地方?我找不到它。
  2. 如何檢索From和Reply-To地址的友好名稱?
  3. 當我以這種方式檢索Body時,它被格式化爲方括號集([]),它隨機散佈在郵件正文中,部分文本不在我期望的位置。

相關代碼:

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

Lotus Notes?我們同情你。 – 2008-11-20 19:06:43

+0

請跟我說說。我已經總結了我們,IBM是唯一使用它的兩家公司......而且我聽說IBM的部分公司使用Outlook。 – tsilb 2008-11-20 19:13:58

+0

我只是準備好低下這個兔子洞。這篇文章已經過去幾年了。任何可能幫助我的提示/技巧?除了「不這樣做」這不是一個選項:-) – Scott 2013-02-12 02:27:16

回答

2

哈,知道了!

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" <[email protected]> 
5: Principal  "example" <[email protected]> 
6: From   "IE130057945714t"<[email protected]> 
7: SendTo  [email protected] 
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  <[email protected]> 
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 

現在,誰可以告訴我爲什麼身體狀態越來越搞砸了?

1

Body項是NotesRichTextItem,而不是常規NotesItem。它們是Lotus Notes世界中的一種不同類型的對象(並且經常是開發人員非常沮喪的原因!)

我沒有太多的使用COM連接到Domino的經驗,並且我知道有什麼區別您有權訪問,但Domino Designer幫助應爲您提供很多類的信息,例如NotesRichTextItem。

也許「GetFormattedText」方法比訪問該項目的Text屬性更適合您。

這裏的方法的一個例子(從Domino Designer幫助拍攝)

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 
0

它可以不依賴於你的環境是如何設置的工作,但要對付郵件多米諾最簡單的辦法就是離開他們作爲MIME並通過NotesMIMEEntity和NotesMIMEHeader獲取值。這隻適用於郵件從網絡傳入而不是本地Notes,並且環境已設置爲以MIME格式存儲郵件的情況。

否則,您需要以NotesRichTextItem身份訪問主體。從這個項目你需要得到一個NotesRichTextNavigator,如果你需要的話,它可以讓你在豐富的文本結構中移動。

如果您認爲struture應該比較簡單,請嘗試調用NotesRichTextItem.GetFormattedText()。如果這仍然不起作用,那麼您需要通過玩一個示例doument並查看NotesRichTextNavigator的結構看起來發生了什麼。