0
votes

I want to create a new document in javascript and generate a new mail with it. I fill the body, sendto and subject of the mail and then I want to open the mail in Lotus Notes Client.

How can I open this mail in the mail client?

2
Hi M. Schaetzl, how do you create the mail? Did you use the SSJS code from Mark Leusink?Michael Saiz
Not yet. I tried the mail creation before I found the solution of Mark Leusink. So in the future I will use that one as far as possibleM. Schaetzl

2 Answers

2
votes

This button creates a new mail with content in the To field, Subject field and Body field coming from fields on the XPage (using client-side Javascript). The logic works with whatever defailt mail client you have (IBM Notes, MS Outlook and other mail clients).

<xp:button id="sendMail" label="Send mail">
    <xp:eventHandler event="onclick" submit="false">
        <xp:this.script><![CDATA[
        window.location.href="mailto:" + encodeURIComponent(dojo.byId("#{id:mailTo}").innerHTML) + "?subject=" + encodeURIComponent(dojo.byId("#{id:mailSubject}").innerHTML) + "&body=" + encodeURIComponent(dojo.byId("#{id:mailBody}").innerHTML);
        ]]></xp:this.script>
    </xp:eventHandler>
</xp:button>
0
votes

I've solved it this way: - Click on a button to create the SendTo, Subject and HTML-Body of the Mail - Then a new XPage opens containing the contents of the Mail - I can edit them now or just click on a button "Send Mail" - Using the SSJS code from Mark Leusink I then send the HTML Mail

var mail = new HTMLMail();
mail.setTo( docMail.getItemValue("SendTo") );
mail.setSubject( docMail.getItemValue("Subject") );
mail.addHTML( docMail.getItemValue("dBody") );
mail.send();

The advantage in this case is, that I can save the mail in the database and not in the mail file of the current user.