gpt4 book ai didi

c# - 无法从文本框传递变量

转载 作者:太空宇宙 更新时间:2023-11-03 21:47:56 24 4
gpt4 key购买 nike

在线

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 string subject = "hello" + textBox1.Text  ;

使用

string subject = "hello" + textBox1.Text;

关于c# - 无法从文本框传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15991831/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com