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

问题描述

如何从sql数据库发送包含应附加到正文的数据的邮件.请任何人现在帮助我.

How to send mail that contains data from sql database that should be attached to body. Please anyone help me now.

推荐答案

Using System.Net.Mail



示例代码:



Sample Code :

MailMessage Mail = new MailMessage();<br />        MailAddress mailAdd = new MailAddress(txtFrom.Text,txtName.Text);<br />        Mail.From = mailAdd ;<br />        Mail.To.Add(txtTo.Text);<br />        Mail.Subject = txtSubject.Text;<br />        Mail.Body = ReadMailBody(); // Read data from Database<br />       try<br />        {<br />            SmtpClient Objsmtp = new SmtpClient();<br />	    Objsmtp .Host = "myMailServer"; <br />            Objsmtp .Send(Mail);<br />          <br />        }<br />        catch (Exception ex)<br />        {<br />            //Handel Exception<br />        }






这篇关于邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 15:23