如何通过不带网络凭据的C#通过电子邮件发送联系信息。
答案 0 :(得分:1)
如果您在域中,请使用此client.UseDefaultCredentials = true;
。下面的例子:
private void Send()
{
using (SmtpClient client = new System.Net.Mail.SmtpClient("server", 25)) // 25 - port number
{
// Configure the client
client.UseDefaultCredentials = true;
MailMessage message = new MailMessage(
"email from", // From field
"Recipient", // Recipient field
"Hello", // Subject of the email message
"message"// Email message body
);
client.Send(message);
}
}