views:

259

answers:

2

Is it possible to update an entry in Lotus Notes via email just like posterous? If it is possible, how can i do that? Thanks.

+1  A: 

Quite easy.

What you need to do is create an agent in the mail database which will process the incoming mail (this will require Domino Designer and the appropriate privileges in the mail DB).

Depending on your requirements, you can trigger the agent periodically (e.g., once an hour) or on a specific event (e.g., when new mail arrives).

All the agents I've ever written are in LotusScript (sort of VBA) and they can scan documents in the database, examining the status, headers and so on, to decide what to do.

One recent one I wrote for someone here follows. When called, it basically runs through the InBox checking each document for a subject heading containing "qwertyuiop", and creates a response email back to the sender containing the same subject with "SUCCESS" appended.

Then it moves the document from the InBox to the junk folder. This particular agent ran every 60 minutes since immediate response was not required. You should be able to pick up the intent from the code.

Sub Initialize
    Dim s As New notessession
    Dim db As notesdatabase
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim olddoc As NotesDocument
    Dim subj As String
    Dim newdoc As NotesDocument

    Set db = s.CurrentDatabase
    Set view = db.GetView("($InBox)")
    If Not view Is Nothing Then
        Set doc = view.GetFirstDocument
        While Not doc Is Nothing
            Set olddoc = doc
            Set doc = view.GetNextDocument(doc)
            subj = olddoc.GetFirstItem("subject").Text
            If Instr(subj, "qwertyuiop") > 0 Then
                Set newdoc = New NotesDocument(db)
                newdoc.SendTo = olddoc.GetFirstItem("inetfrom").Text
                newdoc.subject = subj & " SUCCESS"
                newdoc.form = "Memo"
                Call newdoc.send(True,True)
                Call olddoc.RemoveFromFolder( "($InBox)")
                Call olddoc.PutInFolder( "junk")
            End If
        Wend
    End If
End Sub

What you probably need is a slight modification to this which will open up a different database and change documents in there based on the mail documents.

All you really need is a key in the email that can identify which document in the secondary database should be changed, and some logic that can apply the changes based on the mail content.

That's left as an exercise for the reader. What I've given you should be enough to get started (ask another question when you've had a play with this).

paxdiablo
A: 

Very easy. In Notes you can setup any database to be a target for email. It gets its own eMail ID (e.g. [email protected]). Then you write an agent that runs on "when new eMail arrives". The new documents are in the session.currentdatabase.unprocesseddocuments collection. Your email must of course contain something that allows you to figure out what document to update. Notes uses internally the NotesDocumentUniqueID as primary key, but I guess you would rather pick a business field. Using NotesMimeEntry you can access HTML formatted content in your email in case you emailed a form or so.

stwissel