0
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);
        }
    }
}

3 Answers 3

2
msg.IsBodyHtml = true;
Sign up to request clarification or add additional context in comments.

6 Comments

then how do i add call the file?
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 ?
so set the property to true as I've mentioned above. Then in the msg.Body property write a html code
I was use a test.html file outside of the app so it needs to able to read the test.html file.
so open that file and read it to a string object: using (StreamReader sr = new StreamReader(path)) { string str = sr.ReadToEnd(); }
|
0

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.

Comments

0

Off the top of my head

msg.Body = File.ReadAllText("c:\\temp\\somefile.html");
msg.IsBodyHtml = true;

However, if this page has a HTML form in it, it may not work in some mail clients, as some mail clients strip this functionality from the mail before it is displayed to the recipient.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.