使用 ibm Lotus 发送电子邮件 C# smtpclient

发布于 2024-10-19 00:06:34 字数 2220 浏览 3 评论 0原文

我已经浏览了所有答案...这是我的情况

  1. 我需要 C# 代码使用 ibm Lotus 帐户(有用户名和密码)发送电子邮件
  2. 我们的应用程序发送电子邮件的服务器已获得授权
  3. 没有防火墙阻止
  4. IBM Lotus 客户端安装在服务器上。因此无法使用 interop.domino.dll
  5. SMTP 服务已暴露。我有IP地址和端口。无法远程登录并测试它,因为服务器没有远程登录,并且他们不允许我们启用它

  6. 当我运行下面的代码时,我得到连接主动拒绝异常。

是否有任何工作代码示例..或者我在这里遗漏了一些东西..任何故障排除提示将不胜感激。

尝试 { 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

  1. i need C# code to send email using ibm lotus account ( have username and password)
  2. the server from which our app sends out emails is authorized
  3. no firewall stopping
  4. IBM lotus client is not installed on the server. so cannot use interop.domino.dll
  5. 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

  6. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸里的那抹悲凉 2024-10-26 00:06:34

是否尝试过移动

client.UseDefaultCredentials = false;

您之前

client.Credentials = new System.Net.NetworkCredential(...

显然,如果在实际设置客户端凭据之前未设置 UseDefaultCredentials 属性,则不会发送 AUTH 命令。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文