I need to create a html file with subject and body of email and then create an spx pag..when email is sent it has to take this html content in its email and send...how do I attach this html file to th subject and bosy of my email
You can simply read the content of that HTML file in a string variable and then assign its value to message body. You need to make sure that IsBodyHtml is set to true. Example code:
string messageBody = System.IO.File.ReadAllText(Server.MapPath("~/HTML_FILE_PATH/HtmlFile1.htm"));
MailMessage mailMessage = new MailMessage
{
From = new MailAddress(mailFrom),
Subject = subject,
Body = messageBody,
};
mailMessage.IsBodyHtml = true;
hope it helps./.
नमस्ते,
[KaushaL] BlogTwitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
200 Points
691 Posts
how to attach html file content to subject and body of my aspx email page
Jan 30, 2017 01:22 PM|Lexi85|LINK
Hello
I need to create a html file with subject and body of email and then create an spx pag..when email is sent it has to take this html content in its email and send...how do I attach this html file to th subject and bosy of my email
All-Star
31342 Points
7050 Posts
Re: how to attach html file content to subject and body of my aspx email page
Jan 30, 2017 01:40 PM|kaushalparik27|LINK
You can simply read the content of that HTML file in a string variable and then assign its value to message body. You need to make sure that IsBodyHtml is set to true. Example code:
hope it helps./.
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Contributor
2930 Points
1210 Posts
Re: how to attach html file content to subject and body of my aspx email page
Jan 31, 2017 05:57 AM|Deepak Panchal|LINK
Hi Lexi85,
refer the code below.
the same question was asked before on stackoverflow. which was marked as answered.
How to Read HTML out of a webpage and use it as body of HTML Auto-Responder E-Mail
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
200 Points
691 Posts
Re: how to attach html file content to subject and body of my aspx email page
Jan 31, 2017 08:14 AM|Lexi85|LINK
thanks..but how should be the html file format?
I mean subject and body from html means what format should be my html file?