Hello - I am using VS Express 2013 for Windows Desktop.
I am getting the following exception messages when I run my WindowsFormsApplication:A first chance exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
Additional information: The operation has timed out.
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
Additional information: The operation has timed out.
Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Web;
using System.Net.Mail;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
password.PasswordChar = '*';
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage(from.Text, to.Text, subject.Text, body.Text);
SmtpClient client = new SmtpClient(smtp.Text);
client.Port = 465;
client.Credentials = new System.Net.NetworkCredential(username.Text, password.Text);
client.EnableSsl = true;
client.Send(mail);
MessageBox.Show("Mail Sent", "Success", MessageBoxButtons.OK);
}
private void body_TextChanged(object sender, EventArgs e)
{
}
}
}
Can anyone help me find out why the exeptions are occurring and how to fix the problem?
I have been looking for the solution for some time now. I hope sonemone here can give me a hand.
Thanks