使用 ibm Lotus 发送电子邮件 C# smtpclient
我已经浏览了所有答案...这是我的情况
- 我需要 C# 代码使用 ibm Lotus 帐户(有用户名和密码)发送电子邮件
- 我们的应用程序发送电子邮件的服务器已获得授权
- 没有防火墙阻止
- IBM Lotus 客户端安装在服务器上。因此无法使用 interop.domino.dll
SMTP 服务已暴露。我有IP地址和端口。无法远程登录并测试它,因为服务器没有远程登录,并且他们不允许我们启用它
当我运行下面的代码时,我得到连接主动拒绝异常。
是否有任何工作代码示例..或者我在这里遗漏了一些东西..任何故障排除提示将不胜感激。
尝试 { MailMessage 消息 = new MailMessage(); message.From = new MailAddress(from.Text);
message.To.Add(new MailAddress(to.Text));
//message.To.Add(new MailAddress("[email protected]"));
//message.To.Add(new MailAddress("[email protected]"));
//message.CC.Add(new MailAddress("[email protected]"));
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);
}
I have gone through all the answers ... this is my situation
- i need C# code to send email using ibm lotus account ( have username and password)
- the server from which our app sends out emails is authorized
- no firewall stopping
- IBM lotus client is not installed on the server. so cannot use interop.domino.dll
the SMTP service is exposed. i have ip address and port. 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();
message.From = new MailAddress(from.Text);
message.To.Add(new MailAddress(to.Text));
//message.To.Add(new MailAddress("[email protected]"));
//message.To.Add(new MailAddress("[email protected]"));
//message.CC.Add(new MailAddress("[email protected]"));
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否尝试过移动
您之前
显然,如果在实际设置客户端凭据之前未设置 UseDefaultCredentials 属性,则不会发送 AUTH 命令。
Have you tried to move
before
Apparently, if UseDefaultCredentials property isn't set before you actually set client credentials, the AUTH command wont be sent.