Xpages error sending email from application

232 views Asked by At

In some of the document in my application I have a button which sends an email with the document to any email it is in the input field.

It worked, but for some reason, I don't know why, it is not working anymore.

This is the SSJS I have in the button onClick method:

if(docInfo.isNewNote()){
        docInfo.save();
    }
    var thisdoc = docInfo.getDocument(true);
    var tempdoc = database.createDocument();
    tempdoc.replaceItemValue("Form", "Memo");
    tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("Destinatar"));
    tempdoc.replaceItemValue("Subject", "Title");
    var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Corp");


    thisdoc.save(true,true);
    tempbody.appendText("Some text:")
    tempbody.addNewLine(2);
    tempbody.appendText(facesContext.getExternalContext().getRequest().getRequestURL().toString() + 
              "?action=readDocument&documentId=" + thisdoc.getUniversalID());
    tempdoc.send();
    thisdoc.recycle();
    tempbody.recycle();
    tempdoc.recycle();

For some reason I get an error at tempdoc.send() which says:

Error while executing JavaScript action expression
Script interpreter error, line=21, col=17: [TypeError] Exception occurred calling method NotesDocument.send() null
1

There are 1 answers

3
Paul Stephen Withers On

It's worth checking that the sendTo has a value. That is the usual cause for a doc.send() failing.