Sending Email Using Scripts or Hooks
If you’re creating a pipeline, the preferred method of sending an email is to use the SendMail pipelet. However, to create an OC API hook to send email or send email from inside a script, use the dw.net.mail class to construct an email and send it. Use dw.net.mail with the new dw.util.Template class to construct an email using an ISML template.
- With
dw.net.Mail you must set the subject, mail body, and the to, cc, or bcc. If you don’t, the invocation of mail.send() fails with an IllegalArgumentException.
- Any tags provided in a template for
to, from, subject, or other fields are ignored and not used. Only the values provided by the dw.net.Mail.set* arguments are used to generate an email.
- Although a variable called
pdict is accessible from within the ISML template, it isn’t the Pipeline Dictionary. Pipeline Dictionary default data, such as Session, isn’t accessible.
- The
Mail.send() returns the OK status if the email is successfully queued to the internal mailing queue, or ERROR if the email couldn’t be queued. The email itself is placed on the mail queue asynchronously, meaning that it isn’t sent if there’s a problem with the mail server.
The following script uses the dw.net.Mail setter methods to create an email using only simple strings.
The following script uses the dw.net.Mail setter methods to create an email with an HTML body and header information.
");else if(O._boomrl=function(){t()},O.addEventListener)O.addEventListener("load",O._boomrl,!1);else if(O.attachEvent)O.attachEvent("onload",O._boomrl);d.close()}function a(e){window.BOOMR_onload=e&&e.timeStamp||(new Date).getTime()}if(!window.BOOMR||!window.BOOMR.version&&!window.BOOMR.snippetExecuted){window.BOOMR=window.BOOMR||{},window.BOOMR.snippetStart=(new Date).getTime(),window.BOOMR.snippetExecuted=!0,window.BOOMR.snippetVersion=12,window.BOOMR.url=n+"96ZND-LJLSH-JXHC9-F8GQP-6WCGS";var o=document.currentScript||document.getElementsByTagName("script")[0],i=!1,r=document.createElement("link");if(r.relList&&"function"==typeof r.relList.supports&&r.relList.supports("preload")&&"as"in r)window.BOOMR.snippetMethod="p",r.href=window.BOOMR.url,r.rel="preload",r.as="script",r.addEventListener("load",e),r.addEventListener("error",function(){t(!0)}),setTimeout(function(){if(!i)t(!0)},3e3),BOOMR_lstart=(new Date).getTime(),o.parentNode.appendChild(r);else t(!1);if(window.addEventListener)window.addEventListener("load",a,!1);else if(window.attachEvent)window.attachEvent("onload",a)}}(),"".length>0)if(e&&"performance"in e&&e.performance&&"function"==typeof e.performance.setResourceTimingBufferSize)e.performance.setResourceTimingBufferSize();!function(){if(BOOMR=e.BOOMR||{},BOOMR.plugins=BOOMR.plugins||{},!BOOMR.plugins.AK){var n=""=="true"?1:0,t="",a="eyab6kadmwalajqacqeoyaaabjvcwgzo-f-f87df12cd-clienttons-s.akamaihd.net",o="false"=="true"?2:1,i={"ak.v":"41","ak.cp":"1836958","ak.ai":parseInt("1224868",10),"ak.ol":"0","ak.cr":1,"ak.ipv":6,"ak.proto":"h2","ak.rid":"1254312c","ak.r":47499,"ak.a2":n,"ak.m":"dsca","ak.n":"essl","ak.cport":54210,"ak.gh":"23.48.200.203","ak.quicv":"","ak.tlsv":"tls1.3","ak.0rtt":"","ak.0rtt.ed":"","ak.csrc":"-","ak.acc":"","ak.t":"1781209902","ak.ak":"hOBiQwZUYzCg5VSAfCLimQ==Yf2hKJqhCMRLzyoKdL16RUo3ISWxvPBP9x4FRcXelEF7LbNxOWxq1PJHmWGvw26k6uuY5CQz3IO+TRvZnNYALvEw8ZQAtGRbGIkThBKxGqRK1E1mDeqv3wL1V5rQ1A3H9IU9LIC1b2Vb91vAaF33477RxeTY84RjeZ+fj/XGjatKx6heM7CTZtR0lP7vNQW7lf8R0xdoFjBxjJp+GcXcY6p7LkwGbi9qkDliuJlIRiUSy3OkPLTXbPYC2S52+RN4iA5BR2rN8be3PxUZkiEGwAoP7z6hvDTeSJBceMX6/d4Vl9YeLxg+8xpUGhP4c/kDvppM6XbOhaic6moBwe1tTMgKZcDE/FNPbct4ygDNeNSXnmLMYuih3WP5ZgR3WnjmkarFRXo4sVA//9wJD4r3diLUehqV35fFlrEKz6yjjpo=","ak.pv":"87","ak.dpoabenc":"","ak.tf":o};if(""!==t)i["ak.ruds"]=t;var r={i:!1,av:function(n){var t="http.initiator";if(n&&(!n[t]||"spa_hard"===n[t]))i["ak.feo"]=void 0!==e.aFeoApplied?1:0,BOOMR.addVar(i)},rv:function(){var e=["ak.cport","ak.cr","ak.csrc","ak.gh","ak.ipv","ak.m","ak.n","ak.ol","ak.proto","ak.quicv","ak.tlsv","ak.0rtt","ak.0rtt.ed","ak.r","ak.acc","ak.t","ak.tf"];BOOMR.removeVar(e)}};BOOMR.plugins.AK={akVars:i,akDNSPreFetchDomain:a,init:function(){if(!r.i){var e=BOOMR.subscribe;e("before_beacon",r.av,null,null),e("onbeacon",r.rv,null,null),r.i=!0}return this},is_complete:function(){return!0}}}}()}(window);
Thank you for registering at our shop!