jmail.Message msg = new jmail.MessageClass();
msg.Subject = "恭喜你成为CSDN俱乐部成员!";
读取txt文件的内容,给msg.Body
Stream stream = File.OpenRead(Server.MapPath("~/") + "touch.txt"); //网站上有touch.txt
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
string a = reader.ReadToEnd();
stream.Close();
reader.Close();
//写入数据流
FileStream stream1 = new FileStream(Server.MapPath("~/") + "write.txt", FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(stream1);
Random ran = new Random(DateTime.Now.Millisecond);
StringBuilder sb = new StringBuilder(4);
for (int i = 0; i < 4; i++)
{
sb.Append(ran.Next(0, 9));
}
string c = sb.ToString();
writer.Write("<br/>"+"你的CSDN帐号是:" + this.txt_username.Text+"<br/>"+"激活码是:"+sb.ToString()+"<a href='http://localhost:9696/registered/shock.aspx'>现在就去激活</a>");//将激活码、用户名输入到write.text里面 ,并且写一段html代码 将产生的激活码,如何传送到本计算机服务器中的shock.aspx页面里
writer.Close();
stream1.Close();
读取txt文件的内容,给msg.Body
Stream stream3 = File.OpenRead(Server.MapPath("~/") + "write.txt");
StreamReader reader2 = new StreamReader(stream3, Encoding.UTF8);
string b = reader2.ReadToEnd();
stream.Close();
reader.Close();
msg.Body = a+b;
msg.From = "yvi312082007@163.com";
msg.AddRecipient(this.txt_mail.Text);
msg.MailServerUserName = "yvi312082007@163.com";
msg.MailServerPassWord = "邮箱密码";
msg.Charset = "utf-8";
msg.ContentType = "text/html";
msg.Send("smtp.163.com");