Link to home
Start Free TrialLog in
Avatar of davidcahan
davidcahanFlag for United States of America

asked on

System.Net.Mail.MailMessage: Insert Body from File

The body of my email is fairly complicated HTML.  instead of trying to code it all in the code behind file, I'd like to code it in an html file (possibly called BodyOfMessage.htm or BodyOfMessage.txt) and then read/insert the file in as the body of the email.

How do i do this?
ASKER CERTIFIED SOLUTION
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davidcahan

ASKER

yea...knew it was gonna wind up being simple.  thanks
actually...what is that part where you replace the variables?  what variables are you replacing
In your HTML file, you could have something like this

<body>
<p>Dear [Fullname],</p>
<p>Thank you for ordering [productName].</p>
</body>

Then you would replace them like template fields.
emailFile.Replace("[FullName]", obj.FullName)
emailFile.Replace("[productName]", obj.ProductName)
ahhh...ok. that's what i thought but i wasn't sure.  thanks again