17
为什么在发送SMTP电子邮件时出现“无法分配属性”?
我不明白为什么这段代码无法正常工作。我收到一条错误消息,指出无法分配属性 MailMessage mail = new MailMessage(); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "smtp.gmail.com"; mail.To = "user@hotmail.com"; // <-- this one mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body"; client.Send(mail);
274
c#
email
smtpclient