I’m looking for some code that will send an email from view level. The view contains documents with customer details, the client wants to be able to select a document and press an action button that will insert the email address from the form (PartEmail) into the SendTo field and also insert a paragraph of text in the body field.
Well, you can have your button call an Agent that processes the selected documents.
The agent would have code similar to this:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim docMemo As NotesDocument
Dim rtItem As NotesRichTextItem
Set db = session.CurrentDatabase
Set col = db.UnprocessedDocuments
Set doc = col.GetFirstDocument
While Not doc Is Nothing
Set docMemo = db.CreateDocument
Call docMemo.ReplaceItemValue("Form", "Memo")
Call docMemo.ReplaceItemValue("SendTo", doc.GetFirstItem("PartEmail").Values)
Call docMemo.ReplaceItemValue("Subject", "Subject")
Set rtItem = docMemo.CreateRichTextItem("Body")
Call rtItem.AppendText("The text from doc that you want in the e-mail.")
Call docMemo.Send(False)
Set doc = col.GetNextDocument(doc)
Wend
You’ll need to replace the text in the rtItem.AppendText call with the information from your document, but that should give you a good start.