I created my org email address to send email to my user in windows form, i tried sending email to and fro to my gmail in the servers, it went well, but when i incorperated the code to my C# windows form is not working, it only load and letter pop a message "Operation Time Out"
Below is my code
try
{
// SMTP Client Configuration
SmtpClient smtpClient = new SmtpClient("mail.orag.com")
{
Port = 465,
Credentials = new NetworkCredential("[email protected]", "Testing1234@@"),
EnableSsl = false,
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network
};
MailMessage mail = new MailMessage
{
From = new MailAddress("[email protected]"),
Subject = "Test Email - NOTSPAMTAG",
Body = "This is a test email",
IsBodyHtml = false
};
mail.To.Add("[email protected]");
smtpClient.Send(mail);
MessageBox.Show("Email Sent Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (SmtpException smtpEx)
{
MessageBox.Show($"SMTP Error: {smtpEx.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine($"SMTP Error:{smtpEx.Message}");
}
catch (Exception ex)
{
MessageBox.Show($"General Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}