How do I use AppleScript to get e-mail addresses, account information from Lotus Notes?
We have a mailbox containing roughly 60,000 e-mails, and I've been challenged to pull the names, account numbers and e-mail addresses out of the body of each and export it into a spreadsheet-friendly format.
I was thinking of using AppleScript and Not开发者_如何学运维es 8.5, but I can't find any documentation on how to interact with individual messages in Notes.
Can anyone help?
If you're familiar with scripting languages, I suggest going with LotusScript instead. It gives you direct access to the Notes objects rather than Applescript and the Notes C API.
You can create a Notes Agent within the mailbox using the Notes Designer application. The code would roughly be this:
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
The question is how are the email addresses, account numbers, and names stored in the body of each email?
You could pull all the text out of the body of the emails into a large text file, perhaps, and then process that with Applescript, if you're more comfortable with that.
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
Or you could use the NotesRichTextItem methods to navigate and extract specific data from the body. This could be useful, perhaps, if the data is stored in tables within the body of the email, as the NotesRichTextItem methods allow you to find a table element and navigate cells (although this is rather difficult, and might be worth posting a second question on StackOverflow to get help with this).
If you're looking to get the email address and names from the To: or From: fields of the email, you can do that more easily by accessing properties of the NotesDocument for each email. The fields could be extracted like so:
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)
精彩评论