I have tried repeatedly to send an attachment using the following code. I have used Port 25, 465, 467 and 587 with all resulting in the same error. I have scoured through other posts with the same problem or close to the same problem and tried many of the fixes involved but none worked for me. HELP!
try
{
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential("thisisjustatestokay1@gmail.com", "xxxxxxxxxxxx")
};
using (var message = new MailMessage("thisisjustatestokay1@gmail.com", "thisisjustatestokay1@gmail.com")
{
Subject = "Boom Baby!",
Body = "The stuff!"
})
{
smtp.Send(message);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}