Home > Domino Tips > Developer > LotusScript > Copy email and attachments to a Lotus Notes database using LotusScript
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Copy email and attachments to a Lotus Notes database using LotusScript


Brian Moore
05.15.2007
Rating: -3.20- (out of 5)


Lotus Notes and Domino tips, tutorials and how-to articles
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication

LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication
LotusScript filters and attaches files to a Notes form

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts