C#的MailMessage发送邮件如何设置Content-Disposition和Content-Type,请高手指教 5

C#的MailMessage发送邮件如何设置Content-Disposition和Content-Type,请高手指教... C#的MailMessage发送邮件如何设置Content-Disposition和Content-Type,请高手指教 展开
 我来答
bjddd192
2010-09-18 · TA获得超过416个赞
知道小有建树答主
回答量:496
采纳率:0%
帮助的人:437万
展开全部
public static void SendEmail(string fromname,
string senderemail,
string senderserver,
string senderuser,
string senderpassword,
string emails,
string subject,
string txt,
string[] files, string encoding)
{
using (MailMessage mailmess = new MailMessage())
{
mailmess.From = new MailAddress(senderemail, fromname, Encoding.GetEncoding(encoding));

mailmess.To.Clear();
foreach (string destemail in emails.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
if (destemail.Contains(":"))
{
string[] mailInfo = destemail.Split(':');
mailmess.To.Add(new MailAddress(mailInfo[0].Trim(), mailInfo[1].Trim()));
}
else
{
mailmess.To.Add(destemail);
}
}
mailmess.Subject = subject;
mailmess.SubjectEncoding = Encoding.GetEncoding(encoding);
mailmess.Body = txt;
mailmess.BodyEncoding = Encoding.GetEncoding(encoding);
foreach (string path in files)
{
if (!string.IsNullOrEmpty(path))
mailmess.Attachments.Add(new Attachment(path));
}

SmtpClient client = new SmtpClient(senderserver);

client.Credentials = new NetworkCredential(senderuser, senderpassword);

try
{
client.Send(mailmess);
}
finally
{
}
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式