Manage Learn to apply best practices and optimize your operations.

Copy email and attachments to a Lotus Notes database using LotusScript

Learn how to add a LotusScript-generated button to users' email that will copy an entire email, including attachments, to a Lotus Notes database with a single click.

This LotusScript code will reside in a button in Lotus Notes users' email. One click will allow them to copy an entire email, including attachments, to a Lotus Notes database. This method is much easier than the alternative of forwarding or copying and pasting email.

The QueryClose code at the end makes the new Lotus Notes document a response of the document selected in the target database. The view, "AdminCustomer UNID," lists all entries in alphabetical order.

More LotusScript resources:
FAQ: LotusScript

LotusScript Learning Guide

LotusScript Reference Center

 Sub Click(Source As Button)
 Dim workspace As 
New NotesUIWorkspace
 Dim picklist As Variant
 Dim messagelist As String
 Dim originDoc As NotesDocument
 Dim custDoc As NotesDocument
 Dim resDoc As NotesDocument
 Dim resUIDoc As NotesUIDocument
 Dim originUIDoc As NotesUIDocument
 Set originUIDoc = 
workspace.CurrentDocument
 Set originDoc = originUIDoc.Document
 'First, select the 
customer we are going to attach this to  
 picklist = workspace.PickListStrings
(PICKLIST_CUSTOM,False,"servername",
"database.nsf", "AdminCustomer UNID", 
"Database Title", "Please select the customer.", 5 )
 Forall plist In picklist
  messagelist =
 messagelist & plist
 End Forall
 'Second, we are going to 
compose an Email doc
 Dim bidDB As 
New NotesDatabase("servername","database.nsf")
 Set emailDoc = New NotesDocument(bidDb)
 emailDoc.Form = "tmpResponse" 
 emailDoc.Topic = "Email"
 emailDoc.Subject = "Incoming - 
" & originDoc.Subject(0)
 emailDoc.ResDate = 
originDoc.PostedDate(0)
 emailDoc.ParUNID = messagelist
 Dim rtitem As NotesRichTextItem
 Set rtitem = 
New NotesRichTextItem( emailDoc, "resRich")
 Dim success As Variant
 success = 
originDoc.RenderToRTItem( rtitem )
 Set emailUIDoc = 
workspace.EditDocument(True, emailDoc) 
End Sub


"tmpResponse" is a copy of the form 
"Response" in the target database with this:

Sub Queryclose(Source As 
Notesuidocument, Continue As Variant)
 Set workspace = 
New NotesUIWorkspace
 Set sess = New NotesSession
 Set db = sess.CurrentDatabase
 Set uidoc = 
workspace.CurrentDocument 
 Set doc = uidoc.Document 
 Dim parDoc As Notesdocument
 doc.Form = "Response"
 Set parDoc = db.
GetDocumentbyUNID(doc.ParUNID(0))
 Call doc.MakeResponse(parDoc) 
 Call doc.Save(True,False)
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Brian Moore. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close