使用带有C#的amazon服务器east1发送电子邮件不起作用

时间:2016-07-15 01:12:06

标签: c# email vbscript smtp telnet

我有一个旧的应用程序,它发送一些带有vb脚本的电子邮件,如下所示:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Test Auto Email 20 Min Cycle Completed"
myMail.From="registers@mysite.com"
myMail.To="mehdi@mysite.com"
myMail.TextBody="Auto Email 20 Min Cycle Completed"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="email-smtp.us-east-1.amazonaws.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing

现在我将此代码转换为C#,这是我写的不起作用的代码:

using (var smtpClient = new System.Net.Mail.SmtpClient("email-smtp.us-east-1.amazonaws.com", 465))
{
    smtpClient.EnableSsl = true;
    smtpClient.UseDefaultCredentials = false;
    smtpClient.Credentials = new system.Net.NetworkCredential("username", "password");
    smtpClient.Timeout = 10000;
    smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    smtpClient.Send("registers@mysite.com", "mehdi@mysite.com", "Test" , "Test");
}

我还尝试使用Telnet连接到亚马逊服务器,但这是不成功的。奇怪的是,当我运行脚本时,它会发送电子邮件。

由于

0 个答案:

没有答案