我编译这段代码,它没有错误。但是在命令提示符下运行EXE时,会出现错误"16-bit ms-dos subsystem"
错误对话框。我不知道为什么,因为在我更新Windows XP之前,它的工作正常。
代码有什么问题吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var fromAddress = new MailAddress("aaa@gmail.com", "System");
var toAddress = new MailAddress("bbb@gmail.com", "Receiver");
const string fromPassword = "xxx";
const string subject = "Message";
string body = args[0];
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
}
}
}
答案 0 :(得分:1)
答案 1 :(得分:1)