public void SendEMail()
        {
            MailMessage mail = new MailMessage();
            mail.Priority = MailPriority.High;
            mail.From = "[email protected]";
            mail.To = "[email protected]";
            mail.Subject = "Send EMail System Demo";
            mail.Body = "Just for test.";
            mail.BodyEncoding = Encoding.UTF8;            // authorization
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 1);
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", mail.From);
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress", mail.From);
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "[email protected]");
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "cbf0921");
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.163.com");            SmtpMail.SmtpServer = "smtp.163.com";
            SmtpMail.Send(mail);
        }

解决方案 »

  1.   

    邮件直接做成aspx文件,发送之前利用page的exec转换成HTML在发送。这个做法比较简单。
      

  2.   

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
     
            Dim mg As MailMessage = New MailMessage()
            mg.From = New MailAddress("[email protected]")       '发件人邮箱
            mg.To.Add("[email protected]")                              '收件人邮箱
            mg.Subject = "邮件测试"                                                   '邮件主题
            mg.Body = "测试邮件,,内容为空"                                       '邮件内容
            mg.BodyEncoding = System.Text.Encoding.UTF8                '内容编码
            mg.IsBodyHtml = True                                                       '是否支持HTML格式
            mg.Priority = MailPriority.High                                             '优先级别
            mg.Attachments.Add(New Attachment("c:\ps.txt"))                '添加附件
            Dim smtp As SmtpClient = New SmtpClient()
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network             '邮件发送方式.这里通过网络
            smtp.Host = "smtp.qq.com"                                                  '邮件发送服务器
            smtp.Credentials = New NetworkCredential("113620916", "******")    '用户名跟密码
            Try
                smtp.Send(mg)
                Label2.Text = "OK"
            Catch ex As Exception
                Label2.Text = ex.ToString
            End Try
        End Sub
    -------------------------------------------------------------------
    记得imports system.net.mail