[英]send email C# smtpclient using ibm lotus
I have gone through all the answers ... this is my situation 我已经解决了所有答案...这是我的情况
the SMTP service is exposed. SMTP服务已公开。 i have ip address and port.
我有IP地址和端口。 cant telnet to it and test it becasue server does not have telnet and they will not allow us enabling it
无法远程登录到它并对其进行测试,因为服务器没有远程登录,并且他们不允许我们启用它
When i run the code below i get connection actively refused exception. 当我运行下面的代码时,我得到连接被主动拒绝的异常。
Is there any working code sample .. or am i missing something here .. any trouble shooting tips will be appreciated. 有任何有效的代码示例..还是我在这里缺少任何东西..任何解决问题的技巧都将受到赞赏。
try { MailMessage message = new MailMessage(); 尝试{MailMessage message = new MailMessage(); message.From = new MailAddress(from.Text);
message.From =新的MailAddress(from.Text);
message.To.Add(new MailAddress(to.Text));
//message.To.Add(new MailAddress("recipient2@foo.bar.com"));
//message.To.Add(new MailAddress("recipient3@foo.bar.com"));
//message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "Test email from cogniti";
message.Body = "Test email from Cogniti";
SmtpClient client = new SmtpClient();
client.Port = Convert.ToInt32(port.Text);
client.Host = smtp.Text;
client.Credentials = new System.Net.NetworkCredential(username.Text, passwordBox1.Password);
//client.UseDefaultCredentials = true;
if (ssl.Text.Equals("1"))
client.EnableSsl = true;
else
if (ssl.Text.Equals("2"))
client.EnableSsl = false;
else
client.EnableSsl = false;
client.UseDefaultCredentials = false;
client.Send(message);
MessageBox.Show("Message Sent to: " + to.Text);
}
catch (Exception e3)
{
MessageBox.Show(e3.Message);
MessageBox.Show(e3.InnerException.ToString());
MessageBox.Show(e3.Source);
MessageBox.Show(e3.StackTrace);
}
Have you tried to move 你有没有尝试过
client.UseDefaultCredentials = false;
before 之前
client.Credentials = new System.Net.NetworkCredential(...
Apparently, if UseDefaultCredentials property isn't set before you actually set client credentials, the AUTH command wont be sent. 显然,如果在实际设置客户端凭据之前未设置UseDefaultCredentials属性,则不会发送AUTH命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.