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