Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Best practice: Intercepting mails sent via mail-tag in a operationBinding, Enhancement: multi-pass Velocity

    Hi Isomorphic,

    is there some way in 6.1p (12.0 would also be OK, I guess) to only use the mail-tag in a operationBinding as it is for html-template Velocity-evaluation and mail generation, but not actually send the mail and instead get it from the DSReponse for further processing?
    I'd like to further process it myself (perhaps only get the mail-text and send it on a different way and/or attach files to the mail).

    Another thing in this area: Is two-pass (or even more) Velocity possible?
    For me, 1st pass would be to get language related pieces from the DB, 2nd pass would be to replace content here. This way it would be possible for the user to create their own templates or at least for me to have different templates (with different CI) for different tenants in the DB. This would not be possible with html-template files (my application is the same on the filesystem level for every tenant).
    IMHO, feeding the mail to Velocity, until there are no changes between input and output (because there are no velocity tags anymore) shouldn't be a problem? If it is a problem, perhaps a backward-compatible way would be to enhance templateFile by a passes-attribute?

    Best regards
    Blama

    #2
    With dsRequest.addToTemplateContext() with isSnippet:true, you can add templated variables that are, in effect, evaluated twice.

    If you need yet more pre-processing, we'd recommend doing it in a DMI then calling addToTemplateContext() with the final result.

    We do not want to add something like a "numPasses" attribute as that seems ripe for confusion around quoting and whether "$" characters are literals or indicate a velocity variable.

    Comment


      #3
      Hi Isomorphic,

      Originally posted by Isomorphic View Post
      We do not want to add something like a "numPasses" attribute as that seems ripe for confusion around quoting and whether "$" characters are literals or indicate a velocity variable.
      Ok, writing it I had it back in my head that there might be some problem, but couldn't directly see it. Of course it's the escaping one. If I'll need to have a template editor for a user, I'll try isSnippet:true.

      Do you have a suggestion for this one as well?
      is there some way in 6.1p (12.0 would also be OK, I guess) to only use the mail-tag in a operationBinding as it is for html-template Velocity-evaluation and mail generation, but not actually send the mail and instead get it from the DSReponse for further processing?
      I'd like to further process it myself (perhaps only get the mail-text and send it on a different way and/or attach files to the mail).
      The idea behind it is that at some point in the future (therefore 12.0 would also be OK for me) I'll have an App and then need to send notifications using Firebase Cloud Messaging.
      I assume that for you it does not make sense to support this like you do for mails using specialized <notification>-tags, because the notification ecosystem is not as standardized as the mail one, which even has Java SDK support. But it would be great if I could use the templateFile and it's Velocity support and then get the result without sending a mail.

      The other reason for this question is that I'll definitely have the request for mails with attachments at some point. Once I use your Charts (some months, looking forward to it), for sure there will be the request to export chart data as PDF (which you are already able to do in the showcase) and include it with a mail.
      Here of course it would be great if one could somehow specify a 2nd serverMethod that returns Object[] in order to attach these to the mail. Perhaps Object[] is not the correct choice because of fileName and mimeType, but you get where I'm going.
      Or is it already possible to add the necessary attachment data to the mail-DSResponse used to write the mails "one mail a row"?

      Thank you & Best regards
      Blama

      Comment


        #4
        We don't currently have a way for you to receive the templated content without sending a message. What we'd recommend for that and sending attachments is just direct use of Velocity and Java mail. It's not very much code. However, if it seems really important to have our system send it, we could add the necessary APIs via Feature Sponsorship.

        Comment


          #5
          Hi Isomorphic,

          yes, I thought of that, too. If it is not that complicated, I'll then use that (manual Velocity), because it really is only about easy template-processing.

          What about the mail attachments, do you have a suggestion here, too?

          Best regards
          Blama

          Comment


            #6
            Yes, we did:

            What we'd recommend for that and sending attachments is just direct use of Velocity and Java mail.

            Comment


              #7
              Ahh, sorry. It's getting late. That one might really be a good one for a Feature Sponsorship because I'm relying on <mail>-tags currently and that system works just fine.

              For the (non-attachment) notifications I'll try manual Velocity.

              I'll let you know when this does become important for me.

              Thanks again,
              Blama

              Comment


                #8
                For everyone finding this thread via search - this is also related.

                Best regards
                Blama

                Comment

                Working...
                X