[英]Send mail from Exchange Server
我想從交換服務器發送郵件而無需密碼。 我使用以下代碼片段:
MailMessage msg = new MailMessage();
msg.From = new MailAddress("kavitham@test.com");
msg.To.Add(new MailAddress("kavitham@sample.com"));
msg.Subject = "Reg : Mail test";
msg.IsBodyHtml = true;
msg.Body = "<html><body>" + strMsg + "</body></html>";
SmtpClient client = new SmtpClient("IP of Server", 25);
client.Host = "IP of Server";
client.Send(msg);
但是郵件沒有發送。 是否需要對Exchange服務器進行任何其他設置?
加上這個
smtpClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
MailMessage msg = new MailMessage("noreply@test.com", "manager@test.com", "Notification For Lead / Admin ",
"Emp Name :" + EmpName);
msg.Body = "Emp Name : " + EmpName + "<br /><br >" + Environment.NewLine + timsheetMail;
msg.IsBodyHtml = true;
msg.CC.Add(toMail); msg.CC.Add(admin);
SmtpClient SMTPServer = new SmtpClient("mail.myserver.com", 25);
SMTPServer.Timeout = 300000;
SMTPServer.EnableSsl = false;
SMTPServer.Credentials = new System.Net.NetworkCredential("noreply@test.com", "passw0rd");
SMTPServer.Send(mailObj);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.