Read our top 7 articles-
Simple Steps to Send Mail from an xPage
xPage Mail send : Mail send is the most important feature, lotus notes has inbuilt capability to send and accept mails. XPages is newly designed element to accept web2.0 technology, it has some different scripting techniques. Most of them are known, as we know we use lot of mail sending script in our traditional lotus script mail send code. If we moved to new XPages design then we have to change some scripting notations for mail send feature. Here we have shown simple demonstration of mail send, you can replace your lotus script mail send code with below server side JavaScript code.
Simple Steps to Send Mail from an xPage
xPage Mail send : Mail send is the most important feature, lotus notes has inbuilt capability to send and accept mails. XPages is newly designed element to accept web2.0 technology, it has some different scripting techniques. Most of them are known, as we know we use lot of mail sending script in our traditional lotus script mail send code. If we moved to new XPages design then we have to change some scripting notations for mail send feature. Here we have shown simple demonstration of mail send, you can replace your lotus script mail send code with below server side JavaScript code.
Add this code
on any trigger event on your XPage.
var
currentDB:NotesDatabase=session.getCurrentDatabase(); // Set your current
database
var
mailmemoDoc:NotesDocument=currentDB.createDocument(); // creare bew maildoc
document
var Doc =
document1.getDocument(); // get the handle of your document control which you
want
mailmemoDoc.replaceItemValue("Form","Memo");
// Mail memo form
mailmemoDoc.replaceItemValue("SendTo","yourmailaddress@maildomain.com");
// your mail address
mailmemoDoc.replaceItemValue("Subject","xpage
mail send"); // Mail Subject
mailmemoDoc.replaceItemValue("body",
" This is mail body Text only");// Your mail body content only as
text
Or you can use
dynamic mail subject by fetching “Doc” handle using getItemvalue method
mailmemoDoc.send();
// send mail command
The above
defined method is the simple mail send method, if you are familiar with lotus
script mail send code you can easily understand the above code. For reference
we have written lotus script mail send below
Now, if you
want to attach some doc link or attachment then use rich text item class
Below are the few
lines will show you, How to add rich text in mail?
var
RTBody:NotesRichTextItem=mailDoc.createRichTextItem("Body");
// set body to
Item as notes richest item
RTBody.appendTable(1,1);
// append some new lines to display mail in proper formant
RTBody.appendDocLink(currentDoc,
"Click to the document"); //
Here is the document link
Some other
parameter /object’s you can attach to open in mail file
RTBody.appendDocLink(currentDB,
"Click to the document")
RTBody.appendDocLink(yourobject,
“Click to the view)
RTBody.update();
// update method to update the rich text item in memo form to process all
pending rich text items
Lotus Script
Mail Send –
Dim Session as
new notes session
Dim
currentDB=session.currentdatabase() // Notes session class
Set mailmemoDoc
= currentDB.createdocument // Notes database class
Call
mailmemoDoc.ReplaceItemValue("Form","Memo"); // Mail memo
form
Call
mailmemoDoc.ReplaceItemValue("SendTo","yourmailaddress@maildomain.com");
// your mail address
Call
mailmemoDoc.ReplaceItemValue("Subject","xpage mail send");
// Mail Subject
Call
mailmemoDoc.ReplaceItemValue("body", "This is mail body Text
only");// Your mail body content
This is simple
mail send form, it’s a simplified version of mail send in Lotus script, compare
xPage mail send and lotus script mail send, you will get exact idea and you
will find that there is no difference except scripting language notation with
same structure.
Also the similar way to add attachment to lotus script mail, set rich text body class to “Body”
field from Mail file database to Memo form.
Dim richtext as
NotesrichtextItem
Set RTBody =
New NotesRichTextItem( doc, "Body" )
There are
similar methods for Rich text class for XPage that you can use with rich text
item class , below are the some rich text items methods that you can incorporate to your mail send code whenever you required.
Methods :
EmbeddedObjects(
for server side JavaScript)
getFormattedText
( for server side JavaScript)
getNotesFont (
for server side JavaScript)
getUnformattedText
( for server side JavaScript)
embedObject
(for server side JavaScript)
update (for
server side JavaScript)
appendParagraphStyle
(for server side JavaScript)
appendRTItem
(for server side JavaScript)
addPageBreak
(for server side JavaScript)
compact (for
server side JavaScript)
Refer lotus
notes help file to get more methods for Rich text item class.
Comments