How to send an email through an javascript

naveens49375819

09-04-2018

Hi Jean,

I am trying to send an email using submit delivery method but getting an following error.

09/04/2018 09:35:41 SCR-160012 JavaScript: error while evaluating script 'WKF11540/js'.

09/04/2018 09:35:41 SOP-330011 Error while executing the method 'SubmitDelivery' of service 'nms:delivery'.

09/04/2018 09:35:41 DLV-490051 Failed to analyze delivery (identifier 'unknown').

09/04/2018 09:35:41 DLV-490050 The XML document to add to the scenario does not have a valid format.

09/04/2018 09:35:41 Element 'targetPart' is unknown (see definition of element '/targets' in schema 'Deliveries (nms:delivery)').

Can I pass targets and content inside submit delivery method?

Thanks

Naveen S

Accepted Solutions (1)

Accepted Solutions (1)

Answers (7)

Answers (7)

Jean-Serge_Biro

MVP

09-04-2018

oh your 2nd post and mine have been posted simultaneously

annother example, if you must use it within a webApp Javascript activity:

nms.delivery.QueueNotification('internal-name-of-delivery',

<delivery>

  <targets>

    <deliveryTarget>

      <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>

        <where>

          <condition expr={'@id ='+ ctx.recipient.@id}/>

        </where>

      </targetPart>

    </deliveryTarget>

  </targets>

</delivery>);

Regards

JS

naveens49375819

10-04-2018

Hi Jean,

I have created a template and utilizing that template internal name and trying to target population dynamically by passing email through variable and content too dynamic.

I have removed type="query" and Submitdelivery its working fine now but I couldn't be able to pass email address has a variable inside experssion.

here is the code

var abc = "<html><body><p>xxx</p></body></html>"

var emailId = "abc.xyz@yyy.com"

var deliveryId = nms.delivery.SubmitDelivery("DM79018",<delivery>

<targets >

    <deliveryTarget >

      <targetPart    exclusion='false'  ignoreDeleteStatus='false'>

        <where>

          <condition expr={'@email=' +emailId}/>

        </where>

      </targetPart>

    </deliveryTarget>

  </targets>

                                  <content>

                                    <html>

                                      <source>{abc}</source>

                                    </html>

                                  </content>

                                </delivery>);

                               

                                logInfo(deliveryId)

Jean-Serge_Biro

MVP

10-04-2018

Hi Naveens,

SubmitNotification method is only useful for continuous deliveries (adding new target contacts, not for changing the delivery content).

I mentioned it because of the 2 other methods described in the documentation for target feed (external file etc).

It is weird why an error still occurs after type='query' added. Sorry I don't undertand. Is the mistake the same?
Is your delivery DM79018 a standard one, or recurrent one, or continuous one ?

(in that latter case, again it is Submit Notification that must be used, but with no content change.)

Can you copy/paste the xml code in a text editor (such as Notepad++, Ultraedit, etc) in order to see if you have special characters in it, not visible/shown as blank char?

Please may you try also with :

            <where filteringSchema="nms:recipient"> 

                <condition expr="@email = 'xxxx@yyyy.com'"/> 

Regards

JS

Jean-Serge_Biro

MVP

09-04-2018

Hi Naveen,

Please may you read the SubmitNotification method in the JSAPI.chm documentation, it is more detailed about the 3 possibilities for the target element than submitDelivery method (for which the documentation doesn't give any example, except one in JSON but not for target  part).

For instance, in the SubmitDelivery method, you can write:

<targets > 

    <deliveryTarget> 

        <targetPart> 

            <where filteringSchema="nms:recipient"> 

                <condition expr="@email = 'xxxx@yyyy.com'"/> 

            </where> 

        </targetPart> 

    </deliveryTarget> 

</targets >

Regards
J-Serge

naveens49375819

09-04-2018

Here is the code.

var abc = "<html><body><p>text</p></body></html>"

var deliveryId = nms.delivery.SubmitDelivery("DM79018",<delivery>

<targets >

    <deliveryTarget >

      <targetPart  exclusion='false'   ignoreDeleteStatus='false'>

        <where>

          <condition expr="@email = 'naveen@xyz.com'"/>

        </where>

      </targetPart>

    </deliveryTarget>

  </targets>                                  <content>

                                    <html>

                                      <source>{abc}</source>

                                    </html>

                                  </content>

                                </delivery>);

                               

                                logInfo(deliveryId)