01.
public
void
send_mail()
02.
{
03.
MailMessage mail =
new
MailMessage();
04.
mail.From =
new
MailAddress(textBox1.Text);
05.
mail.To.Add(textBox3.Text);
06.
mail.Subject = textBox5.Text;
07.
mail.Body = textBox4.Text;
08.
if
(textBox6.Text !=
""
)
09.
{
10.
mail.Attachments.Add(
new
Attachment(textBox6.Text));
11.
}
12.
SmtpClient smtpServer =
new
SmtpClient();
13.
smtpServer.UseDefaultCredentials =
true
;
14.
15.
smtpServer.Port = 25;
16.
smtpServer.Host =
"xx.xx.xx.xxx"
;
17.
smtpServer.EnableSsl = checkBox1.Checked;
18.
19.
try
20.
{
21.
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate
(
object
s,
22.
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
23.
System.Security.Cryptography.X509Certificates.X509Chain chain,
24.
System.Net.Security.SslPolicyErrors sslPolicyErrors)
25.
{
26.
return
true
;
27.
};
28.
smtpServer.Send(mail);
29.
MessageBox.Show(
"Mail Send Success Fully"
);
30.
}
31.
catch
(Exception ex)
32.
{
33.
MessageBox.Show(ex.Message,
"Information"
);
34.
}
35.
36.
}