Qaiser Abbas
Qaiser Abbas

Reputation: 113

Document Link in Xpages based application for Rich and Web Client

I am looking for best way to compose an email and attach document link for notes and web client using SSJS.
We are doing it one way but I think there is some good way of doing this. I want to use complete functionality of Rich Text Item e.g. formating, styles and other which we normally do in LotusScript.

Any sample application having industry standard way of doing this will be great help.
Following is sample code how we are doing right now.

var stream = session.createStream();        
stream.writeText("Application is forwarded to you for approval. "); 
var var3 = '<a href =' + notesDocLink + '> Open in Rich Client (Doc Link) </a>'
var var4 = '<a href =' + webDocLink + '> Open in Internet Explorer  </a>'

stream.writeText( var3 + " For web Client Use this link: " + var4 , 2);
stream.writeText("Note: This is auto-generated email and do not require any reply. ");      
mailBody.setContentFromText(stream, "text/html; charset=iso-8859-1", 0);        
mailDoc.replaceItemValue("SendTo",mailSendTo);
mailDoc.replaceItemValue("CopyTo",mailCopyTo);      
mailDoc.send();

I am interested in something like this which is currently not working for me.

mailDoc.replaceItemValue("Form","Memo");
mailDoc.replaceItemValue("Subject" , strSubject);

var RTItem:NotesRichTextItem = mailDoc.createRichTextItem("Body");

RTItem.appendText("Leave Application is forwarded to you for approval. ");
RTItem.addNewLine(2);
RTItem.appendText("Please click on below document link for details. ");
RTItem.appendDocLink(currDoc, "Click on Link to Proceed")
RTItem.addNewLine(2);
RTItem.appendText("Note: This is auto-generated email and do not require any reply. ");     

RTItem.addNewLine(2);

mailDoc.replaceItemValue("SendTo",mailSendTo);
mailDoc.replaceItemValue("CopyTo",mailCopyTo);      
mailDoc.send(); 

Upvotes: 0

Views: 337

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15729

For doc links, please confirm that the answer to this question doesn't solve your problem Getting an Error message when trying to appendDocLink is SSJS.

There are a couple of code examples for emails on XSnippets:

Mark Leusink's creation of email as MIME http://openntf.org/XSnippets.nsf/snippet.xsp?id=create-html-mails-in-ssjs-using-mime

Tony McGuckin's emailBean: http://openntf.org/XSnippets.nsf/snippet.xsp?id=emailbean-send-dominodocument-html-emails-cw-embedded-images-attachments-custom-headerfooter

For anyone using the OpenNTF Domino API, this has a DominoEmail class, for creating an email as well.

In R9 there is also a Send Mail simple function.

Personally, I'd prefer HTML and MIME for styling compared to the RichTextStyle classes. It also gives greater flexibility for web links as well as client. It has the added benefit of fidelity when sending outside Notes. Even for Notes users viewing on mobile devices via Traveler, I think the Traveler server will have to convert to MIME to ensure the styles are available, so it's easier to cut out that step by using MIME for a start.

Upvotes: 1

Related Questions