send email C# smtpclient using ibm lotus

2019-08-13 02:07发布

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("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);
        }

1条回答
叛逆
2楼-- · 2019-08-13 02:57

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.

查看更多
登录 后发表回答