Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Templates...

Templates...

Scheduled Pinned Locked Moved C#
helpcsharpdatabasewpfalgorithms
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    quiteSmart
    wrote on last edited by
    #1

    hi all, I don't know if i can express my problem right but i hope you can understand what i am looking for. let's start... for an application i am developing (windows application), there is a kind of mail servicing. This mail servicing should send mails to the clients on a certain condition that i test using data from the database. I had a problem with the client in defining the template that the mail should be sent uppon. I asked the client to define a default template to be used in all the mails and by having it i can enter it in the code. The client asked if i can leave it undefined. Meaning he wants to be able to change the template whenever he wish. He needs a special page for that. I was thinking of something like the word templates, but till now i have no idea what should i do. I had never worked with microsoft office tools in C# coding. I think it is not so hard... anybody can give me a clue. by the way i tried searching the code project for a start but i couldn't find any article that helps. (maybe i didn't search correctly) i didn't try googling yet cause, concerning code, i believe that what i can't find in codeproject i can't find anywhere. Thanks for any help given.

    C 1 Reply Last reply
    0
    • Q quiteSmart

      hi all, I don't know if i can express my problem right but i hope you can understand what i am looking for. let's start... for an application i am developing (windows application), there is a kind of mail servicing. This mail servicing should send mails to the clients on a certain condition that i test using data from the database. I had a problem with the client in defining the template that the mail should be sent uppon. I asked the client to define a default template to be used in all the mails and by having it i can enter it in the code. The client asked if i can leave it undefined. Meaning he wants to be able to change the template whenever he wish. He needs a special page for that. I was thinking of something like the word templates, but till now i have no idea what should i do. I had never worked with microsoft office tools in C# coding. I think it is not so hard... anybody can give me a clue. by the way i tried searching the code project for a start but i couldn't find any article that helps. (maybe i didn't search correctly) i didn't try googling yet cause, concerning code, i believe that what i can't find in codeproject i can't find anywhere. Thanks for any help given.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You want them to be able to write a template for email text ? Just define special keys for the values you want to insert, such as <MAILTO>, and then you can use regex to replace them with the values you have for each email.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      Q 1 Reply Last reply
      0
      • C Christian Graus

        You want them to be able to write a template for email text ? Just define special keys for the values you want to insert, such as <MAILTO>, and then you can use regex to replace them with the values you have for each email.

        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

        Q Offline
        Q Offline
        quiteSmart
        wrote on last edited by
        #3

        Christian Graus wrote:

        You want them to be able to write a template for email text ?

        That's right..

        Christian Graus wrote:

        Just define special keys for the values you want to insert, such as ,

        That is what i was thinking of doing. but i don't know how to insert a template creating tool inside my application or coding one or something like that. and i don't know how to define those special keys. Christian your always the savor in those situations thanks:)

        C 1 Reply Last reply
        0
        • Q quiteSmart

          Christian Graus wrote:

          You want them to be able to write a template for email text ?

          That's right..

          Christian Graus wrote:

          Just define special keys for the values you want to insert, such as ,

          That is what i was thinking of doing. but i don't know how to insert a template creating tool inside my application or coding one or something like that. and i don't know how to define those special keys. Christian your always the savor in those situations thanks:)

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Well, your template will just be a string. Your keys will be things that a user won't ever type otherwise, so I presented it looking like a node: , but it could be $MAILTO, or even MAILTO if you like. The point is to come up with something consistent, and the user will just type a template into a textbox, such as $POSTALADDRESS Dear $MAILTO, Thank you for downloading a demo version of $THEPROGRAM. As you're aware, this demo will expire on $EXPIREDATE. We hope you've enjoyed the demo, if you have any questions, don't hestitate to ask us, your designated contact at $COMPANYNAME is $CONTACTEMAIL. Regards, $MAILFROM And so, you just load that into a string, and for each email, make a copy, then call the replace method on the string class to replace each of the keys with the value for that email.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          Q 1 Reply Last reply
          0
          • C Christian Graus

            Well, your template will just be a string. Your keys will be things that a user won't ever type otherwise, so I presented it looking like a node: , but it could be $MAILTO, or even MAILTO if you like. The point is to come up with something consistent, and the user will just type a template into a textbox, such as $POSTALADDRESS Dear $MAILTO, Thank you for downloading a demo version of $THEPROGRAM. As you're aware, this demo will expire on $EXPIREDATE. We hope you've enjoyed the demo, if you have any questions, don't hestitate to ask us, your designated contact at $COMPANYNAME is $CONTACTEMAIL. Regards, $MAILFROM And so, you just load that into a string, and for each email, make a copy, then call the replace method on the string class to replace each of the keys with the value for that email.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            Q Offline
            Q Offline
            quiteSmart
            wrote on last edited by
            #5

            ok man thanks a lot, one more question please am i able to insert a background picture or a logo or something like that. thanks a lot

            C 1 Reply Last reply
            0
            • Q quiteSmart

              ok man thanks a lot, one more question please am i able to insert a background picture or a logo or something like that. thanks a lot

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Well, you're rendering it, so you can render it over a bitmap if you want to.  I expect you can also insert a bitmap into an email, although I'm not exactly sure.

              Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

              D 1 Reply Last reply
              0
              • C Christian Graus

                Well, you're rendering it, so you can render it over a bitmap if you want to.  I expect you can also insert a bitmap into an email, although I'm not exactly sure.

                Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                D Offline
                D Offline
                donchev_p
                wrote on last edited by
                #7

                I suppose he wants to send an html formated mail message with a custom background. You can use the approach above, but if you need preview you will need to use something like BrowserControl to render how the html formatted message will look like. If this is the question you can follow the steps below : 1. Present the user with some relevant interface to create the templates. 2. Define some kind of macro language so you can insert the variables you need in the text. 3. Make the text html, save it temporarly (or not temporarly) on the hard drive and load it to an WebBrowse control so the user can see the result, before save the template. Hope it helps.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups