7
我使用outloook 2003和visual studio 2008.我想開發一個將電子郵件發送到任何域的應用程序。但我的代碼失敗時,我試圖發送電子郵件到Gmail,Hotmail等實際上所有的郵件存儲在C:\Inetpub\mailroot\Queue
目錄。請幫助我如何將電子郵件發送到Gmail,Hotmail的A/C。如何使用C#中的SMTPclient向Gmail發送電子郵件?
由於提前
代碼是
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("[email protected]");
message.To.Add("[email protected]");
message.Subject = "This is sample mail";
message.From = new System.Net.Mail.MailAddress("[email protected]");
message.Body = "this is the message body";
System.Net.Mail.SmtpClient sss = new System.Net.Mail.SmtpClient("HO-KKJ-MAIL.in.niit.com");
sss.UseDefaultCredentials = false;
sss.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
sss.Credentials = new System.Net.NetworkCredential("Sumit.Dhingrar", "password","domain");
您的憑證是否正確?你有任何錯誤信息? – Mizipzor 2011-04-18 08:16:25
嘗試'sss.EnableSsl = true;' – KaeL 2011-04-18 08:18:25