Announcement Announcement Module
Collapse
No announcement yet.
Mailing in Spring Framework Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mailing in Spring Framework

    Hello All,
    I am creating a small web app which sends out mail for marketers, so I have created beans the application content, which have different mail factories .For respective mail factory we have templates. Now my requirement is to change the content of the templates dynamically as well as storing that HTML template at a location so that my server can pick it up which I send my for that marketer guy.
    Please let me know if you guys have any thoughts or ideas on this.

  • #2
    Hi jaistage

    Could you elaborate a bit more? I am unable to understand especially the following sentence:

    Originally posted by jaistage View Post
    storing that HTML template at a location so that my server can pick it up which I send my for that marketer guy.
    Rgds
    guybrush

    Comment


    • #3
      Dynamic:Mail

      I mean that my mail templates are stored in a folder in my tomcat, if I change that email template from a JSP page (the contents in the template) how would they be written in that file in the tomcat.
      I want to say that my templates are kept at a location outside my normal WAR, is there a way to update these templates on the server through the web ???

      Comment


      • #4
        Don't know if this helps:

        We are using freemarker for the view layer and thus for all templates.
        The templates are stored localized in the classpath.

        The template:
        ==========
        Hello ${login}
        We welcome you at ....
        Please click the link below to activate your account
        http://.../user/register/confirmkey?invitationKey=${invkey}

        The model-object:
        // contains the tokens
        Map<String, String> model = new HashMap<String, String>();

        // our model should now about
        model.put(EMAIL_CONTENT_LOGIN, identity.getLogin());
        model.put(EMAIL_CONTENT_INVKEY, identity.getInvitationKey());

        The main code to fetch the replace the tokens in the template looks like:
        msg = FreeMarkerTemplateUtils.processTemplateIntoString( mailTemplateEngine.getTemplate(EMAIL_CONFIRMATION_ TEMPLATE,locale,ENCODING_DEFAULT,true) ,model);

        This way freemarker picks up a template from the classpath, parses it and replaces the tokens by the params

        does this help ???

        Comment


        • #5
          It sounds like the poster wants to give clients the ability to modify the templates on-the-fly via a web interface.

          Certainly a java class can save text to a file anywhere on the file system; it need not be within the web path. So one option is to load up the template contents into a JSP, edit them, and save using a FileWriter or some such. Note that you can't save just the changes -- you have to delete and save the whole thing.

          Another option (the one we have chosen to use) is to put the templates into a database. We're using Velocity and you can use VelocityEngine.evaluate to do the template substitution with any string (such as a template string retrieved from a database). Happy to post code if you need.

          Comment


          • #6
            Originally posted by jacobmattison
            Another option (the one we have chosen to use) is to put the templates into a database.
            This sounds reasonable. I think I'd have a funny feeling in my stomach letting the (web-)app write "anywhere" in the filesystem.

            Rgds
            guybrush

            Comment


            • #7
              Thanks a lot Jacob,
              I am looking into the way you have mentioned will let you know soon.

              Comment

              Working...
              X