please guys I am trying to send an email with an attachment to a user but it is showing the exception "The CLR has been unable to transition from COM context 0xf444f0 to COM context 0xf445a8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations". i dont really understand, please help me
private void proto_Type_AI_(object sender, RoutedEventArgs e)
{
try
{
MailMessage mail = new MailMessage();
//put your SMTP address and port here.
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
//Put the email address
mail.From = new MailAddress("favourakak@gmail.com");
//Put the email where you want to send.
mail.To.Add("favourakak@gmail.com");
mail.Subject = "hello";
StringBuilder sbBody = new StringBuilder();
sbBody.AppendLine("testing face");
//mail.Body = sbBody.ToString();
//Your log file path
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(@"C:\XML\see.xml");
mail.Attachments.Add(attachment);
//Your username and password!
SmtpClient clientDetails = new SmtpClient();
clientDetails.Credentials = new System.Net.NetworkCredential("EYO AKAK", "08186998699");
//Set Smtp Server port
clientDetails.Port = 465;
clientDetails.EnableSsl = true;
//SmtpClient oSmtp = new SmtpClient();
//oSmtp.Send(mail, clientDetails);
MessageBox.Show("Hello User Your Mail Has Been Sent");
SmtpServer.Send(mail);
Console.WriteLine("working very well");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}