如何在C#中发送电子邮件 [英] how to send email in c#

查看:107
本文介绍了如何在C#中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Asp.net 3.5中,我必须单击一个按钮后才向客户端发送邮件.实际上我必须发送一个表.一切正常,但是未显示该表的应用样式.如何编写样式?

In Asp.net 3.5 I have to send a mail to client after clicking a button.Actually I have to send a table.All is ok.But The applied style to that table is not shown.How to Write the style?

推荐答案

您可以直接通过SMTP协议发送邮件:
http://msdn.microsoft.com/en-us/library/system. net.mail.smtpclient.aspx [ ^ ]
或通过WCF类:
http://social.msdn.microsoft.com/Forums/br/wcf/thread/97c64c4a-1d1a-447d-98c8-bd1f73247e9b [
You can send mails either directly trough the SMTP protocol:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx[^]
or through the WCF class:
http://social.msdn.microsoft.com/Forums/br/wcf/thread/97c64c4a-1d1a-447d-98c8-bd1f73247e9b[^]


MailObject.IsBodyHtml = true;
如果要发送html:格式,表格等.
MailObject.IsBodyHtml = true;
if you want to send html: format, table etc..



您应该尝试MyMailObj.IsBodyHtml = true;.试试这个:
Hi,
You should try MyMailObj.IsBodyHtml = true;. Try this:
System.Web.Mail.MailMessage oMsg = new System.Web.Mail.MailMessage();
// TODO: Replace with sender e-mail address.
oMsg.From = "enquiry@xyz.com";
// TODO: Replace with recipient e-mail address.
oMsg.To = "saj@xyz.com";
oMsg.Subject = "Enquiry 99gates";
// SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.BodyFormat = System.Web.Mail.MailFormat.Html;
// HTML Body (remove HTML tags for plain text).
oMsg.Body = content; 
// In this content use StringBuilder and design your body of email.
//Replace with the name of your remote SMTP server.
//SmtpMail.SmtpServer = "144.16.78.76";
SmtpMail.Send(oMsg);
oMsg = null;





--Amit





--Amit


这篇关于如何在C#中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆