Daily Archives: October 10, 2008

Alternative SMTP server

Yesterday I discovered that about half of all emails sent using my ISP’s SMTP server are rejected by my recipient’s mail servers. The reason: since a long while my personal ISP, Online (former Orange, even more former Wanadoo) is blacklisted for spam reasons.

As I understand when surfing the Internet for this problem, many users suffer from the same problem. I decided it was time to do something myself, as I cannot rely on the SMTP server anymore. Therefore I looked for a reliable SMTP relay server (paid, to prevent myself to overcome the same problem again). That particular relay server must support the Exchange Server’s smart host on an alternative SMTP port, since Online has closed port 25.

Since a couple of hours I use the mail relay service of DNSexit for just a few bucks per year. All functions wonderful, my mail arrives again (not unimportant). I also tried using SMTP2GO, but unfortunately they do not support an Exchange Server smart host.

Multicast delegate invocation

Today I remembered the need to blog again. It sounds weird, but it isn’t :) … A while ago I ran into a failing multicast delegate and decided to blog it. Since I ran into one again today and having to look up my previous solution again the hard way, I discovered I should have done it immediately. Check the story below:

Multicast delegates are great. Today I had to implement a custom user control (insurance cost calculation) with several child controls (one for each prospect) which depend on each other (e.g. parent and children). I use a delegate to notify the parent control that one of it’s children selections has changed.

The original call:

public event EventHandler SelectionChanged;

/// <summary>
/// This method cares for correct event handling
/// </summary>
private void OnSelectionChanged()
{
  // The SelectionChanged event will be null if there are no subscribers.
  if (SelectionChanged != null) SelectionChanged(this, EventArgs.Empty);
}

For some dumb reason I ran into a NRE using the delegate. Guess what happened? Subsequent delegate subscribers did not get fired anymore. The reason is that a delegate that fails for some reason, fails entirely. After researching the problem again, I changed the code provided hereabove with the following piece of code:

public event EventHandler SelectionChanged;

/// <summary>
/// This method cares for correct event handling, including the protection against
/// failing individual event subscribers
/// </summary>
private void OnSelectionChanged()
{
  // The SelectionChanged event will be null if there are no subscribers.
  if (SelectionChanged != null)
  {
    try
    {
      Delegate[] list = SelectionChanged.GetInvocationList();
      foreach (Delegate del in list)
      {
        try
        {
          // Only the current subscriber will file, the rest of the delegate's
          // invocation will proceed as normal.
          EventHandler handler = (EventHandler) del;
          handler(this, EventArgs.Empty);
        }
        catch { }
      }
    }
    catch { }
  }
}