send email C# smtpclient using ibm lotus

陌路散爱 提交于 2019-12-11 13:46:34

问题


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:


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.



来源:https://stackoverflow.com/questions/5101281/send-email-c-sharp-smtpclient-using-ibm-lotus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!