SendCompleted CallBack does not trigger RRS feed

  • General discussion

  •   Hi Guys, I am sending mail with the following code(not full)

    SC.SendCompleted += new SendCompletedEventHandler(SmtpClient_OnCompleted);
    SC.SendAsync(Mailer, UserState);

    public static void SmtpClient_OnCompleted(object sender, AsyncCompletedEventArgs e)
    System.Net.Mail.MailMessage mail = (System.Net.Mail.MailMessage)e.UserState;

    if (e.Error != null)
    MessageBox.Show("SNM CallBack Errors" + mail.Subject + " " + e.Error.ToString());
    MessageBox.Show("SNM CallBack no errors" + mail.Subject);

    But my callback procedure only gets called sometimes... Most of the time it does not. The AppendDebug function just writes to disk.

    Anyone know why that might be?


    Tuesday, July 22, 2008 11:45 AM

All replies

  • There's not enough information here to answer the question.

    In TCP/IP protocol is everything.  If an onCompleted event is not being triggered, then it is likely, very likely that the critieria to trigger that event never happened.  So what you have to do, is to go back in your code to the last thing that was done waiting for the event.  You'll probably find the issue there.

    Good Luck!

    P.S. Running sniffer traces is about the only way to debug this stuff.  It's the number 1 method to "see" what's happening. 
    Tuesday, July 22, 2008 12:02 PM
  • I have a try{}catch() around the SC.SendAsync(Mailer, UserState); statement in my real code, and so I know there is no immediate error. 

    I assume then that all other errors would trigger the SendCompleted event. Is that not the case?

    Tuesday, July 22, 2008 12:17 PM
  •  You think you know here is no error which perhaps there is not anything that violates protocol on the Asynchronous send, but what was the response to that send?  Run a sniffer trace, then we can get somewhere.
    Tuesday, July 22, 2008 1:12 PM
  • Javaman,

    That's my point. there is no response... Try/Catch run SendAsynch gives no error, and I get no callback.

    What is a sniffer trace?
    Tuesday, July 22, 2008 1:21 PM
  • No I think you're missing mine, you have to run a trace to see what's going on at the line level.
    Tuesday, July 22, 2008 6:00 PM