Aug 19, 2015, 4:03 PM
21 Posts

How to set the From field

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 9.0.1
  • Role: Administrator,Developer,End User
  • Tags: email
  • Replies: 5


 If I send an email from javascript, the email arrives with the From field containing "Anonymous%<Notes domain>".  I tried setting the fields "reply-to", "return-path", "From", "Sender", & "Principal".  But that often results in a bounce-back because (I think) it appears that the From address is being spoofed so the email is rejected.  How can I set the From field?



Aug 20, 2015, 12:21 AM
110 Posts
If you have access to the appropriate

Then you can try create the mail there. I haven't tried this with SSJS but back in lotusscript I have done this. Just make sure to just save the document. No need to do a send method. The will route it later.

Aug 20, 2015, 10:18 AM
21 Posts
re: If you have access to the appropriate

I have used that technique in LotusScript.  Hadn't thought of using that in javaScript.  I'll test that but I seem to think there's a similar issue.  But I'll give it a try.  Thanks!



Oct 13, 2015, 10:05 AM
21 Posts

Thanks for the replies.  I ended up using the technique.  In case anyone else needs it, here's the code:


 Create the body field.

    var body:NotesRichTextItem = doc.createRichTextItem("body");
    body.appendText("Four score and seven years ");
    body.appendText("ago our fathers brought forth on this continent, );
    body.appendText("a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal..");
    var subject = "The Gettysburg Address"
    var emailAddr = ""

    sendEmailViaMailBox(emailAddr, subject, body);

function sendEmailViaMailBox(emailAddr, subj, rtBodyFld){
    var mailboxdb:NotesDatabase = sessionAsSigner.getDatabase("<server name>", "");
    var emaildoc:NotesDocument = mailboxdb.createDocument();
    emaildoc.replaceItemValue("form", "Memo");
    emaildoc.replaceItemValue("sendTo", emailAddr);
    emaildoc.replaceItemValue("Recipients", emailAddr);
    emaildoc.replaceItemValue("subject", subj);
    //emaildoc.replaceItemValue("body", rtBodyFld);
    emaildoc.copyItem(rtBodyFld, "body");
    emaildoc.replaceItemValue("SMTPOriginator", "");
    emaildoc.replaceItemValue("From","\"\" <>");
    emaildoc.replaceItemValue("Principal","\"\" <>");;