2 Replies - 1875 Views - Last Post: 24 November 2010 - 10:38 AM Rate Topic: -----

#1 ramo1995  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 38
  • Joined: 24-July 10

Why does the Send-Email Program Freeze?

Posted 24 November 2010 - 09:43 AM

Hi. I made a small program in which I can basically send an email through the yahoo smtp server. My Code:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net;
using System.Net.Mail;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
                try
                {

                    MailMessage message = new MailMessage();
                    message.From = new MailAddress("myid@yahoo.com");
                    message.To.Add("anotherid@yahoo.com");
                    message.Subject = "afdasdfasfg";
                    message.Body = "Hgfk4564267862738I";
                    message.IsBodyHtml = true;
                    message.Priority = MailPriority.High;
                    SmtpClient sC = new SmtpClient("smtp.mail.yahoo.com");
                    sC.Port = 587;
                    sC.Credentials = new NetworkCredential("myid", "mypassword");
                    //sC.EnableSsl = true;
                    sC.Send(message);
                    MessageBox .Show ("Mail Send Successfully");
                    
                }
                catch (Exception ex)
                {
                    MessageBox .Show (ex + "Mail Sending Fail's") ;
                    
                }
            }
            
        }
    }
          





The bizarre thing is that it worked for the first week. I could send messages with no problem. Then just yesterday, the program just starts freezing and doesn't respond( I didn't change the code). Why did this happen? How can I mend my program?

Thanks for your help!

Is This A Good Question/Topic? 0
  • +

Replies To: Why does the Send-Email Program Freeze?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8963
  • View blog
  • Posts: 33,617
  • Joined: 12-June 08

Re: Why does the Send-Email Program Freeze?

Posted 24 November 2010 - 10:17 AM

If it's hanging then it is probably waiting for a response back from Yahoo. Probably yahoo trying to figure out why you are sending out spam emails! Hahaha..
Was This Post Helpful? 0
  • +
  • -

#3 ramo1995  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 38
  • Joined: 24-July 10

Re: Why does the Send-Email Program Freeze?

Posted 24 November 2010 - 10:38 AM

View Postmodi123_1, on 24 November 2010 - 09:17 AM, said:

If it's hanging then it is probably waiting for a response back from Yahoo. Probably yahoo trying to figure out why you are sending out spam emails! Hahaha..



But unfortunately, it doesn't have anything to do with spam. I changed the address and it stopped arriving as spam. So I guess it is something else!

Another point:

Right now I just tried the program and left it for a whole minute then an error showed:

ContextSwitchDeadlock was detected

Message: The CLR has been unable to transition from COM context 0x21eb78 to COM context 0x21ece8 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.

This post has been edited by ramo1995: 24 November 2010 - 10:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1