using System;
using System.Net;
using System.Net.Mail;
class MainClass
{
public static void Main(string[] args)
{
SmtpClient client = new SmtpClient("192.168.1.12", 25);
using (MailMessage msg = new MailMessage())
{
msg.From = new MailAddress("[email protected]");
msg.Subject = "***Dexter DB***";
msg.Body = "***DB backup done***"; // I want to change this so i can do this in html file - how do i pick up this file and send a html form?
msg.To.Add(new MailAddress("[email protected]"));
client.Send(msg);
}
}
}
Add a comment
|
3 Answers
msg.IsBodyHtml = true;
6 Comments
neilos
then how do i add call the file?
Tony
like that: msg.Attachments.Add(new Attachment(@"C:\windows\win.ini")); Do you want to add a html attachment or have a html formatted mail message ?
Tony
so set the property to true as I've mentioned above. Then in the msg.Body property write a html code
neilos
I was use a test.html file outside of the app so it needs to able to read the test.html file.
Tony
so open that file and read it to a string object: using (StreamReader sr = new StreamReader(path)) { string str = sr.ReadToEnd(); }
|
Construct a Mulipart Mime Message, using the System.Net.Mail.Attachment class.
The part containing HTML has a mime type of text/html.
You can modify the example on the reference page to specify a part without disposition and filename.