We have a requirement to allow users to create an email within another database (with full mail functionality) and then store a copy of the email in the database aswell as in their Mail File. What is the best way to approach this?
Subject: Create Email within Database and Store
Depends on what you want to do in the mail. Off the top of my head…
You could create the mail in the user’s mail file and then copy (I’d actually suggest rendering to Rich text) the mail to your application DB to keep a record. Will require LotusScript, but should be minimal.
It would be the least amount of work since you’re reusing mail functionality, and be quite future proof (template updates etc.).
Subject: RE: Create Email within Database and Store
Would this not require a change to the mail template?
If you imagine the user is in database A, clicks on button “Send Mail”. The idea is on Send that the document will be stored in the users Sent folder as normal, as well as in the actual database as a reference document.
Subject: Your problem is in 3 parts
a) sending from another databaseb) saving within that database
c) ensuring a copy of the document is in the “sent” view of the users mail database.
Parts (a) and (b) are very straight forward
e.g. in Lotus Script
Note: code not checked for indication only.
’ asumme session is Current NotesSession
’ assume db is the current (non mail database)
Dim doctosend as NotesDocument
set doctosend = db.CreateDocument ’ temporary document in current database
Dim rti as NotesRichTextItem
with doctosend
.from = session.Username
.form = “memo” ’ ensure mail will be rxed in memo format
.subject = “atutomatic mail”
.sendto = whoever
set rti = .CreateRichTextItem( “body”)
’ create mail in RT
’
.Send( false ) ’ send the temporary doc as mail … False implies no embeded form
. Save( True, False ) ’ this saves the mail in current DB
end with
now all this is all very well.
-
You now have a document sent - the mail router takes care of this & its displayed using the recipients mail file
-
You also have it saved in YOUR database - which means you will need a view or views to list them plus a “memo” form IN YOUR DATABASE to show it.
What you dont have is a copy in the senders mail file that will appear in the SENT view (and its a view not a folder)
NOTE: I have often uised the above functionality in my own designs - so I’m pretty sure of what I’m saying.
However, I’ve never tried to ensure the document appears in “Sent”.
In fact I usually make a benefit of it NOT appearing there
(saving space in mail file)
Instead I provide a “My Mail” view in the operating database.
Perhaps you can do the same?
However assuming you can’t
Heres how I’d approach Step(c)
First locate the users mail file
var = Evaluate( {@MailDBname} )
looks good
Second, open that as just anothr database
set maildb = session.Getdatabase( var(0) , var(1) , False)
would be my starting point
Third copy my document to the mail database
set newdoc = doctoSend.CopyTodatabase( maildb )
seems easiest
Third mark the mail document do that it apears in the Sent View
newdoc.PostedDate = Now
call newdoc.Save( True, False )
having got that far,
I would expect you might have to add some new items to the “sent” document to further simulate the sending process and get it to display correctly
Principal come to mind.
However these can be added after a little investigation and experimentation
Good luck and have fun