本文介绍了如何发送HTML邮件格式化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能是能够让Web应用程序使用发送Windows任务计划自动电子邮件。现在,我想用下面的方法我写的发送电子邮件发送HTML格式的电子邮件。

I could be able to let the web application sends automatic emails using Windows Task Scheduler. Now I want to send HTML-Formatted email using the following method that I wrote for sending emails.

我的code-背后:

protected void Page_Load(object sender, EventArgs e)
    {
        SmtpClient sc = new SmtpClient("mail address");
        MailMessage msg = null;

        try
        {
            msg = new MailMessage("[email protected]",
                "[email protected]", "Message from PSSP System",
                "This email sent by the PSSP system");

             sc.Send(msg);
        }

        catch (Exception ex)
        {
            throw ex;
        }

        finally
        {
            if (msg != null)
            {
                msg.Dispose();
            }
        }
    }

如何做到这一点?我只想把一些大胆的文字与电子邮件中的一个环节,也许一个图像。

How to do that? I just want to put some bold text with one link and maybe one image in the email.

推荐答案

真正让你使用HTML标记在邮件正文:

Setting isBodyHtml to true allows you to use HTML tags in the message body:

msg = new MailMessage("[email protected]",
                "[email protected]", "Message from PSSP System",
                "This email sent by the PSSP system<br />" +
                "<b>this is bold text!</b>");

msg.IsBodyHtml = true;

这篇关于如何发送HTML邮件格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 08:24