【发布时间】:2013-04-13 19:14:41
【问题描述】:
上线
const string subject = "hello" + textBox1.Text;
它不会打印 textBox1.Text 的值,但我会打印单词“textBox1.Text”。我该如何解决?
var fromAddress = new MailAddress("samuimark@gmail.com", "samui mail");
var toAddress = new MailAddress("teeramail@gmail.com", "To Name");
const string fromPassword = "t429";
const string subject = "hello" + textBox1.Text ;
const string body = "you have a mail";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
【问题讨论】:
-
试过删除 const 吗?字符串主题 = "你好" + textBox1.Text ;