0
In my lab smtp server is blocked.I had gone through the EAsendmail package but i couldn't succeed in sending email from the application directly without using going through smtp server.
这里是运行此代码我收到超时错误后的代码如何在不使用smtp服务器的情况下自动从.net应用程序发送电子邮件?
SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();
//Set sender email address, please change it to yours
oMail.From = "[email protected]";
//Set recipient email address, please change it to yours
oMail.To = "[email protected]";
//Set email subject
oMail.Subject = "direct email sent from c# project";
//Set email body
oMail.TextBody = "this is a test email sent from c# project directly";
//Set SMTP server address to "".
SmtpServer oServer = new SmtpServer("");//173.194.40.246,"74.125.237.181");
//Set 465 port
oServer.Port = 465;
//detect SSL/TLS automatically
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
//Gmail user authentication
//For example: your email is "[email protected]", then the user should be the same
oServer.User = "[email protected]";
oServer.Password = "";
try
{
Console.WriteLine("start to send email directly ...");
oSmtp.SendMail(oServer, oMail);
Console.WriteLine("email was sent successfully!");
}
catch (Exception ep)
{
Console.WriteLine("failed to send email with the following error:");
Console.WriteLine(ep.Message);
}
。 有没有其他方式发送电子邮件,而不是通过smtp? 有没有办法通过http发送应用程序的电子邮件?
先生,我怀疑即使在我们的实验室smtp服务器已关闭,那么我怎么能够看到我的Gmail。 – raja
那么,首先*接收*邮件工作在不同的端口和不同的协议(IMAP或POP)。其次,对于Gmail,很可能您正在网上查看它,在这种情况下,所有协议都会在Google服务器的幕后发生。你所做的只是通过端口80上的标准HTTP(S)协议发送一个接收位,这将允许非常普遍的。 –