문제

In Client Notes programming there is an action button:

@MailSend(Destinatari;"";"";"Subject";"";"";IncludeDoclink])&
@Command([FileSave])&@Command([FileCloseWindow])

I want to make a similar action in my xpage application which works both in XPiNC and web.

My sendto field is a DjTextarea which can have multiple values.

I tried to create a simple action for my button from xpage: Action: Send Mail. In this way, can I embedded < the IncludeDoclink from Lotus Notes> in the body of the mail? Or I need to write a javascript for this action?

Thanks for your time!

UPDATE: following @Lothar suggestions, my Save & Send button has the following code lines:

if(frmDoc.isNewNote()){
    frmDoc.save();
}
var thisdoc = frmDoc.getDocument();
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("txt_names"));
tempdoc.replaceItemValue("Subject", "subject");
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("This is my Mail, click on the doc link below to open the original doc:")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();

Where frmDoc is my doc datasource. I get an error like: NotesRichTextItem.appendDocLink(lotus.domino.local.Document) null - at the appendDoclink line. - the same error I noticed in the @Fredrik useful suggestion too.

도움이 되었습니까?

해결책

I use the HTML email function that can be found in xSnippets when sending emails in xpages.

XSnippet SSJS HTML Mime emails

or

XSnippet email Bean

None of them as an function for attaching a doclink, but you could manually add an url to the document.

Another way is to create the email manually by creating a document is the database adding a richtextfield called body and a subject and a sendto field. And adding a doclink to the Body field.

var doc:NotesDocument = database.createDocument();
var My_DocLink_Doc:NotesDocument=database.getDocumentByUNID("UNID_of_Document")
doc.replaceItemValue("form", "Memo");
doc.replaceItemValue("sendTo", "the_emailadress");
doc.replaceItemValue("subject", "an email to you");
var RT:NotesRichTextItem=doc.createRichTextItem("Body")
RT.appendText("This is my Text")
RT.addNewLine()
RT.appendDocLink(My_DocLink_Doc)
doc.send();

다른 팁

There's really not much to add to Fredrik's answer, but I'm afraid you might be looking at the wrong pieces of his solution. I just tested it myself, and it's working just fine, so here's the result, step-by-step:

my xpage is bound to a Notes form named testMail using a document datasource called mailDoc. It is built like this:
Control#1 is a textarea with a multiple separator set to a comma, so that I can enter multiple mail addresses separated by commas. The textarea is bound to a Notes field named SendTo:

<xp:inputTextarea
    value="#{mailDoc.SendTo}"
    id="sendTo1"
    multipleSeparator=",">
</xp:inputTextarea>

Control #2 is a simple EditBox control bound to a Notes field named Subject:

<xp:inputText
    value="#{mailDoc.Subject}"
    id="subject1">
</xp:inputText>

A button control labelled Save & Send first saves the current document if it is New (i.e. has never been saved before), then performs all the necessary steps to send a doclink for the currently opened doc (button's onclick event); in the following code I'm using these variables:
mailDoc = my datasource object;
thisdoc = the backend doc object that the datasource is bound to;
tempdoc = a temp backend doc object used to be sent via Notes mail:

if(mailDoc.isNewNote()){
    mailDoc.save();
}
var thisdoc = mailDoc.getDocument();
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("SendTo"));
tempdoc.replaceItemValue("Subject", thisdoc.getItemValue("Subject"));
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("This is my Mail, click on the doc link below to open the original doc:")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();

Result: the button code sends a mail containing a Notes document link to all the recipients that I previously entered in the SendTo field.

If I set the testMail form's property to use the Xpage in Notes (Defaults >> On Open >> Display Xpage instead >> mailSendTest), then this also works for the XPinc version. And if the recipient then clicks on the doc link the originating document of course opens in XPinc mode as well.

Remark:

I need to save the originating doc at least once otherwise the appended doc link might not be usable for the recipients; could this have been the reason why Fredrik's answer didn't work for you?

Hope this helps. If this is working for you please accept Fredrik's answer.

Update:

Changed some variable names in my code example to clarify things

I simply use these two lines:

var url = @Left(facesContext.getExternalContext().getRequest().getRequestURL(),"newDocument.xsp")+"newDocument.xsp?documentId="+document1.getDocument().getUniversalID()+"&action=openDocument"; rtitem.appendText(url);

where newDocument.xsp is the form xsp of the document, rtitem is the rich text field of the mail. That will add the whole link to your document.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top