Convert email to a document in another NSF

i am a newbie when it comes to writing code. i would like to find out if the above is possible.the scenario is as follows:

one.nsf (mail-in database) is to rec. email which contains info in the email body (e.g. pono=123, amount=23000., date=12/12/2007, and a .pdf attachment)

two.nsf (application database) contains a form with the following fields: pono, amount, date, attachment (a rich text field).

when one.nsf rec. a new mail, it triggers an event that parses the email body text and copies the data to two.nsf into the correct fields.

any suggestions to point me to the right direction is greatly appreciated. thanks to all.

Subject: convert email to a document in another NSF

In one.nsf create an agent type After new mail has arrived.

Sub Initialize

Dim Ses As New NotesSession

Dim cDb As NotesDatabase

Dim tDb As New NotesDatabase(“”, “”)

Dim cCol As NotesDocumentCollection

Dim cDoc As NotesDocument

Dim tDoc As NotesDocument

Dim RTI As NotesRichTextItem

Dim Arr As Variant

Set cDb = Ses.CurrentDatabase

Call tDb.OpenByReplicaID(“”, “12345678:12345678”) 'here comes rep id of the two.nsf

If tDb Is Nothing Then Exit Sub

If Not tDb.IsOpen Then Exit Sub

Set cCol = cDb.UnprocessedDocuments

Set cDoc = cCol.GetFirstDocument

While Not cDoc Is Nothing

Set RTI = cDoc.GetFirstItem(“Body”)

If RTI.Type = RICHTEXT Then

Let Arr = ParseContent(RTI.GetUnformattedText, Arr)

Set tDoc = tDb.CreateDocument

Let tDoc.Form = “SomeForm”

Let tDoc.Pono = Arr(0)

Let tDoc.Amount = Arr(1)

Let tDoc.Date = Arr(2)

Call MovePDF(RTI, tDoc)

Call tDoc.Save(True, False)

End If

Call Ses.UpdateProcessedDoc(Doc)

Set cDoc = cCol.GetNextDocument(cDoc)

Wend

End Sub

Function ParseContent must parse text for strings pono=, amount=, date= and return content of those variables to the array.

Function MovePDF must detach PDF file from the Body field to the temporary directory on server harddrive and then attach that file to a newly created richtext field in the tDoc.

To get temporary directory I use following function:

Private Function GetTempDir As String

Select Case Session.Platform

Case “Windows/32”,“Windows/16”,“MS-DOS”

Let GetTempDir = Environ(“TEMP”) & ""

Case “Linux”,“UNIX”

Let GetTempDir = “/tmp/”

End Select

End Function

Enjoy.