我正在使用outlook 2003 和visual studio 2008。我想开发一个将电子邮件发送到任何域的应用程序。但是当我尝试向 gmail、hotmail 等发送电子邮件时,我的代码失败了。实际上所有的邮件都存储在C:\Inetpub\mailroot\Queue
目录中。请帮助我如何将电子邮件发送到 gmail、hotmail a/c。
提前致谢
代码是
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("sumitdawar@hotmail.com");
message.To.Add("sumitdawar@gmail.com");
message.Subject = "This is sample mail";
message.From = new System.Net.Mail.MailAddress("Sumit.Dhingra@niit.com");
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");