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

Hi

 If I send an email from javascript, the email arrives with the From field containing "Anonymous%<Notes domain>@Company.com".  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?

thanks

clem

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

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 mail.box will route it later.

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

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!

 

clem

Oct 13, 2015 10:05 AM
21 Posts
Solution

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

 

 Create the body field.

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

    sendEmailViaMailBox(emailAddr, subject, body);

function sendEmailViaMailBox(emailAddr, subj, rtBodyFld){
    
    var mailboxdb:NotesDatabase = sessionAsSigner.getDatabase("<server name>", "mail.box");
    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", "xyz@abc.com");
    emaildoc.replaceItemValue("From","\"xyz@abc.com\" <xyz@abc.com>");
    emaildoc.replaceItemValue("Principal","\"xyz@abc.com\" <xyz@abc.com>");
    emaildoc.save();
}