邮件发送的问题!以前用03的时候发送成功了!现在还真不会弄了!!

hilarysong 2008-04-09 04:42:53
MailMessage myMail = new MailMessage();
myMail.From = new MailAddress("services@hiharmony.com");
myMail.To.Add(new MailAddress("hilarysong@163.com"));
myMail.Subject = "取回密码!!系统自动发出!!请勿回复!!";
myMail.Priority = MailPriority.High;
myMail.IsBodyHtml = true;
myMail.BodyEncoding = Encoding.UTF8;
myMail.Body = "您好," + UserName + " 您的密码已经被修改。\n"
+ "新密码为:" + PassWord + "\n"
+ "为保证安全!!您可以登陆网站后台通过在线修改密码。\n安达在线 "
+ "http://www.baidu.com"
+ "\n联系方式 \n"
+ "24小时电话 ......\n"
+ "在线QQ群 .....\n"
+ datetime;
SmtpClient SClient = new SmtpClient();
SClient.Host = "smtp.163.com";
SClient.Port = 25;
SClient.EnableSsl = true;
SClient.Send(myMail);

邮件接收不到
...全文
341 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
hilarysong 2008-04-10
  • 打赏
  • 举报
回复
害我白白浪费了分分.....无言
hilarysong 2008-04-10
  • 打赏
  • 举报
回复
我已经崩溃了!!原来是发出去了!!慢 没有收到而已!!!疯了!!结分了!!
我在地球 2008-04-09
  • 打赏
  • 举报
回复
学习
Jack Wang 2008-04-09
  • 打赏
  • 举报
回复
建议使用Jmail组件。

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Util;
using System.Web.Mail;
using Xin.AdvisoryBLL;

namespace Xin.Advisory.Admin
{
public partial class Admin_Mail : System.Web.UI.Page
{
//MailMessage myMail;

protected void Page_Load(object sender, EventArgs e)
{


// if (!IsPostBack)
// {
// fromMail.Text = "dxsxlzx@126.com"; //发送方邮件
// fromMail.Enabled = false;
// }
//}

//private bool SendMail(string fromMail, string toMail, string ccMail,string bccMail,string subject,string fckMessage)
//{
// //try
// //{
// myMail = new MailMessage();
// myMail.From = fromMail;
// myMail.To = toMail;
// myMail.Cc = ccMail;
// myMail.Bcc = bccMail;
// myMail.Subject = subject;
// myMail.Body = fckMessage;

// Response.Write(Xin.AdvisoryBLL.InfoOperate.JavaScriptTest(fromMail));
// Response.Write(Xin.AdvisoryBLL.InfoOperate.JavaScriptTest(toMail));
// Response.Write(Xin.AdvisoryBLL.InfoOperate.JavaScriptTest(subject));
// Response.Write(Xin.AdvisoryBLL.InfoOperate.JavaScriptTest(fckMessage));



// //附件
// string ServerFileName = "";
// if (this.upfile.PostedFile.ContentLength != 0)
// {
// string upFileName = this.upfile.PostedFile.FileName;
// string[] strTemp = upFileName.Split('.');
// string upFileExp = strTemp[strTemp.Length - 1].ToString();
// ServerFileName = Server.MapPath(DateTime.Now.ToString("yyyyMMddhhmmss") + "." + upFileExp);
// this.upfile.PostedFile.SaveAs(ServerFileName);
// myMail.Attachments.Add(new MailAttachment(ServerFileName));
// }


// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 2);
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "dxsxlzx"); //发送方邮件帐户
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "dxsxlzx123");
// SmtpMail.SmtpServer = "smtp." + fromMail.Substring(fromMail.IndexOf("@") + 1);
// SmtpMail.Send(myMail);

// return true;
// //}
// //catch
// //{
// // return true;
// //}
//}

//protected void btnPost_Click(object sender, EventArgs e)
//{
// bool flag = SendMail(fromMail.Text, toMail.Text, ccMail.Text, bccMail.Text, subject.Text,fckMessage.Value);
// if (flag == true)
// {
// Response.Write("<script>alert('发送成功!');</script>");
// }
// else
// {
// Response.Write("<script>alert('发送失败!');</script>");
// }
}

}
}
叶子 2008-04-09
  • 打赏
  • 举报
回复
顶jmail
wapit 2008-04-09
  • 打赏
  • 举报
回复
还是jmail好用.
懒牛科技 2008-04-09
  • 打赏
  • 举报
回复

记得在web.config中添加如下

<system.net>
<mailSettings>
<smtp>
<network host="smtp.metinform.cn" port="25" userName="usernmae" password="666666"/>
</smtp>
</mailSettings>
</system.net>
hilarysong 2008-04-09
  • 打赏
  • 举报
回复
如果有能叫我成功的也结 呵呵
hilarysong 2008-04-09
  • 打赏
  • 举报
回复
今天没时间试了!明天成功就结帖!结头两个了!
winteroffishwinter 2008-04-09
  • 打赏
  • 举报
回复
你换新浪的邮箱!
我也发了个帖子,我的附件发送有问题,不知道怎么解决呢!
peterb 2008-04-09
  • 打赏
  • 举报
回复
使用163邮箱发送email需要验证的

在vs2005中发送邮件的方法如下:


System.Net.Mail.SmtpClient client = new SmtpClient();
client.Host = "smtp.163.com";
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("你的163用户名", "*****");
//星号改成自己邮箱的密码
client.DeliveryMethod = SmtpDeliveryMethod.Network;

System.Net.Mail.MailMessage message = new MailMessage("你的163邮箱地址", "收件人邮箱地址");
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.Octet);
message.Attachments.Add(data);

try
{
client.Send(message);
MessageBox.Show("Email successfully send.");
}
catch (Exception ex)
{
MessageBox.Show("Send Email Failed." + ex.ToString());
}

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧