Results 1 to 3 of 3

Thread: using a textfile template

  1. #1

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    using a textfile template

    Hi

    I have a text file called thankyou.txt

    What I'd like to do is use this file (and others) as a template(s) to generate a customized email response :

    Dear <% Their Name from database %>

    Thank you for your interest in <% item %>



    I've seen examples in classic asp, but can't make heads or tails out of it. Would I load the file and then use response to write it?

    Any help would be greatly appreciated

    Thank you

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: using a textfile template

    You could create the text file in the following format:
    Code:
    Dear {0}
    
    Thank you for your interest in {1}
    Read the text file contents into a string and then use the String.Format method to populate the string. This might not work for more complex messages though.

    Code:
    string populatedEmailText = String.Format(importedTemplateText, userName, product);
    HTH

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  3. #3

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    Re: using a textfile template

    dj4uk

    Thank you - I didn't realize format could be used like that. Could come in real handy for short bits.

    I guess I was hoping there was some way to do a "mail merge" kind of thing (minus the word doc).

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width