+ Reply to Thread
Results 1 to 6 of 6

Thread: Using file as email body

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Using file as email body

    Can I set the email body to the contents of an HTML file using ASP.NET?

    I'm sure you can do it using ASP and CDOSYS, but I can't find a property in MailMessage class in .NET.

    Any ideas?

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Don't think so. What I've done in cases just like this is to read the mail body from a file -- In my case using an XmlReader since I do some additional processing on the file. If you want to just send a static file, a StreamReader should do.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    You can accomplish this by using the System.IO namespace:
    Code:
    string strbodyHTML = File.ReadAllText(txtFileFullPath);
    
    Then, simply set the Body property to strBodyHTML.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  4. #4
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Cool. I had forgotten about that method.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  5. #5
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by Wolffy View Post
    Cool. I had forgotten about that method.
    Sometimes it hurts to be this good
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  6. #6
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by jmurrayhead View Post
    You can accomplish this by using the System.IO namespace:
    Code:
    string strbodyHTML = File.ReadAllText(txtFileFullPath);
    
    Then, simply set the Body property to strBodyHTML.
    Worked like a treat J....Thanks

+ Reply to Thread

Similar Threads

  1. Email Class
    By jmurrayhead in forum .NET Code Samples
    Replies: 3
    Last Post: July 8th, 2011, 08:09 AM
  2. DOS - Re-arrange file parts and build text file
    By tuxalot in forum Windows Scripting
    Replies: 0
    Last Post: December 31st, 2009, 01:50 PM
  3. Excel and Email
    By Chrissy in forum ASP Development
    Replies: 10
    Last Post: February 16th, 2009, 09:11 PM
  4. help with email validation
    By Rebelle in forum JavaScript Programming
    Replies: 13
    Last Post: August 21st, 2008, 11:57 AM
  5. Using dll to send email - Multithreading
    By sync_or_swim in forum ASP Development
    Replies: 1
    Last Post: August 4th, 2008, 11:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

SEO by vBSEO