有这样一段测试代码: using System; using System.Web.Mail;public class sendmail { public static void Main(String[] args) { if (args.Length != 3) { Console.WriteLine("Usage: sendmail sender reciever SMTPServer"); return ; } SmtpMail.SmtpServer = args[2]; // Send the string content Console.WriteLine("Sending mail with string content case..."); SmtpMail.Send(args[0], args[1], "Hello,iNet !", "[string]iNet is the best chance for you now !"); Console.WriteLine("Sent the mail with string content case successfully !"); // Send the MailMessage. MailMessage myMail = new MailMessage(); myMail.From = args[0]; myMail.To = args[1]; myMail.Subject = "Hello,iNet!"; myMail.Priority = MailPriority.High; myMail.Body = "[mailmessage]iNet is the best chance for you now !"; Console.WriteLine("\nSending mail with the mailmessage case..."); SmtpMail.Send(myMail); Console.WriteLine("Sent the mail with the mailmessage case successfully !"); } } 你用你的数据测试一下,如果不行,那是smtpserver的名字错了。
using System;
using System.Web.Mail;public class sendmail
{
public static void Main(String[] args)
{
if (args.Length != 3) {
Console.WriteLine("Usage: sendmail sender reciever SMTPServer");
return ;
} SmtpMail.SmtpServer = args[2]; // Send the string content
Console.WriteLine("Sending mail with string content case...");
SmtpMail.Send(args[0], args[1], "Hello,iNet !", "[string]iNet is the best chance for you now !");
Console.WriteLine("Sent the mail with string content case successfully !"); // Send the MailMessage.
MailMessage myMail = new MailMessage();
myMail.From = args[0];
myMail.To = args[1];
myMail.Subject = "Hello,iNet!";
myMail.Priority = MailPriority.High;
myMail.Body = "[mailmessage]iNet is the best chance for you now !"; Console.WriteLine("\nSending mail with the mailmessage case...");
SmtpMail.Send(myMail);
Console.WriteLine("Sent the mail with the mailmessage case successfully !");
}
}
你用你的数据测试一下,如果不行,那是smtpserver的名字错了。