日期:2014-05-18 浏览次数:20855 次
System.Net.Mail.MailMessage mss = new System.Net.Mail.MailMessage(); mss =new System.Net.Mail.MailMessage("__@__.com","__@__.com"); mss.Subject = "主题"; mss.Body = "内容"; System.Net.Mail.SmtpClient cl = new System.Net.Mail.SmtpClient("服务器",端口); cl.Credentials = new System.Net.NetworkCredential("验证用户名","验证密码"); cl.Send(mss)
------解决方案--------------------
MailMessage mailMessage = new MailMessage();
string strBody;
mailMessage.From=new MailAddress("xxxxxx@163.com"); //发送人
mailMessage.To.Add("xxxxxx@yahoo.com.cn"); //收信人
mailMessage.Subject="Web order";
strBody = "<h2>" + ddlMainTag.SelectedItem.Text + "</h2><br>";
strBody += "<h4>" + tbTag.Text + "</h4><br><hr><br>";
strBody += "·" + tbAdv.Text;
sendMail(mailMessage);
foreach (string bo in c)
{
Bodytext = "邮件内容";
}
objMl.Body = Bodytext;
SmtpMail.Send(objMl);
private void sendMail(MailMessage mail)
{
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Host = "smtp.163.com";
smtpClient.Port = 465;
smtpClient.Credentials = new System.Net.NetworkCredential("p_bings@163.com","hacker");
try
{
smtpClient.Send(mail);
// Label1.Text = "ok";
}
catch
{
Response.Write("发送失败!");
// Label1.Text = "false";
}
}
------解决方案--------------------
System.Net.Mail.SmtpClient client = new SmtpClient();
client.Host = "smtp.163.com"; //郵箱服務器
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("髮件人郵箱名", "密碼");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new MailMessage("髮件人郵箱名", "收件人郵箱名");
message.Subject = "主題";
message.Body = "正文";
//message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
//添加附件
Attachment data = new Attachment(@"附件地址如:e:\a.jpg", System.Net.Mime.MediaTypeNames.Application.Oct