如何使用AppleScript从Lotus Notes获取电子邮件地址和帐户信息?

时间:2011-06-01 20:53:40

标签: applescript lotus-notes

我们有一个包含大约60,000封电子邮件的邮箱,我一直被要求将名称,帐号和电子邮件地址从每个邮件中删除,并将其导出为电子表格友好格式。

我在考虑使用AppleScript和Notes 8.5,但是我找不到任何关于如何与Notes中的单个消息进行交互的文档。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

如果您熟悉脚本语言,我建议改用LotusScript。它使您可以直接访问Notes对象而不是Applescript and the Notes C API

您可以使用Notes Designer应用程序在邮箱中创建Notes代理。代码大致是这样的:

Dim s as New NotesSession
Dim db as NotesDatabase
Dim dc as NotesDocumentCollection
Dim doc as NotesDocument

Set db = s.CurrentDatabase
Set dc = db.Search(|Form="Memo"|, Nothing, 0)
Set doc = dc.GetFirstDocument

While Not (doc Is Nothing)

    'Process each document here...

    Set doc = dc.GetNextDocument(doc)
End While

问题是如何将电子邮件地址,帐号和名称存储在每封电子邮件的正文中?

您可以将电子邮件正文中的所有文本拉成一个大文本文件,然后使用Applescript处理 ,如果您对此更加满意的话。

fileNum = Freefile()
pathname = "C:\path\to\file"
Open pathname For Output As fileNum
While Not (doc Is Nothing)

    Set rtitem = doc.GetFirstItem( "Body" )
    Write #fileNum, rtitem.GetFormattedText(False, 0)

    Set doc = dc.GetNextDocument(doc)
End While
Close fileNum

或者您可以使用NotesRichTextItem方法从正文中导航和提取特定数据。如果数据存储在电子邮件正文中的表中,这可能很有用,因为NotesRichTextItem方法允许您查找表元素并导航单元格(虽然这很难,但可能值得发布第二个问题在StackOverflow上获得帮助)。

如果您希望从电子邮件的“收件人:”或“发件人:”字段中获取电子邮件地址和姓名,则可以通过访问每封电子邮件的NotesDocument属性来更轻松地完成此操作。可以像这样提取字段:

Dim ToEmail as String
Dim FromEmail as String

ToEmail = doc.SendTo(0)   'a document's item properties are zero-based arrays
FromEmail = doc.From(0)  
相关问题