the code works but for a while you can not get an answer from the page and then your message could not be sent. RRS feed

  • Question

  •  private void button1000_Click(object sender, EventArgs e)
                        SmtpClient client = new SmtpClient();
                        MailMessage mesaj = new MailMessage();
                        foreach (var checkedItem in checkedListBox1002.CheckedItems)
                        mesaj.From = new MailAddress(listBox1000.SelectedItem.ToString());
                        client.Timeout = 10000000;
                        mesaj.Subject = textBox1003.Text;
                        mesaj.Body = textBox1004.Text;
                        mesaj.SubjectEncoding = mesaj.BodyEncoding = Encoding.Default;
                        NetworkCredential guvenlik = new NetworkCredential(Convert.ToString(listBox1000.SelectedItem), textBox1001.Text);
                        client.Credentials = guvenlik;
                        client.Port = 587;
                        client.Host = "smtp-mail.outlook.com";
                        client.EnableSsl = true;
                        if (textBox1005.Text.Length > 0 && File.Exists(textBox1005.Text)) { mesaj.Attachments.Add(new Attachment(textBox1005.Text)); }
                        MessageBox.Show("your message has beensent");
                    MessageBox.Show("your message could not be sent.");
    • Edited by Deniz35 Wednesday, August 8, 2018 12:24 PM
    Wednesday, August 8, 2018 12:21 PM

All replies

  • help me please
    Wednesday, August 8, 2018 1:06 PM
  • Do not bump threads. This will get your thread marked as spam.

    Please put code into the code editor. It is not readable simply pasting into the post.

    Your call is synchronous so it'll block until the message has been sent. If it is taking a while then most likely your mail server configuration is wrong. You'll have to validate that yourself as we don't know what you'd be using. Also it would be useful if you posted the exception you're getting. It will almost always tell you exactly what is failing.

    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, August 8, 2018 1:51 PM