Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lynn eriksen 3 posts 23 karma points
    Mar 02, 2012 @ 00:08
    lynn eriksen
    0

    EmailHelper SendAsync bug

    There is a bug in the EmailHelper SendAsync method. If there is no mail server configured, often the case using IIS express in dev environments, the when calling smtp.Send() it will throw an error and cause the server to crash.

    At present the method looks like this:

    private static void SendAsync(object o)
            {
                SmtpClient smtp = ((dynamic)o).smtp;
                MailMessage message = ((dynamic)o).message;
                smtp.Send(message);
            }

    The revised version should look like this:

    private static void SendAsync(object o)
            {
                SmtpClient smtp = ((dynamic)o).smtp;
                MailMessage message = ((dynamic)o).message;
    
                try
                {
                    smtp.Send(message);
                }
                catch (Exception ex)
                {
                    // log exception here!
                    Log.Add(LogTypes.Error, -1, ex.Message);
                }
    
    
            }
    This will fix the issue.
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 02, 2012 @ 00:30
    Anthony Dang
    0

    Thanks.

    I normally specify a mail drop folder when developing:

    <mailSettings>
          <smtp deliveryMethod="specifiedPickupDirectory">
            <specifiedPickupDirectory
              pickupDirectoryLocation="c:\maildrop"
            />
          </smtp>
        </mailSettings>

    http://msdn.microsoft.com/en-us/library/ms164241.aspx

     

     

  • lynn eriksen 3 posts 23 karma points
    Mar 02, 2012 @ 00:46
    lynn eriksen
    0

    For those that do not, having the server just go away is kind of mystifying.

    You do have the the synchronous method wrapped, so wrapping the asyc one wouldn't be much of a stretch. :)

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 02, 2012 @ 00:48
    Anthony Dang
    0

    It's now on the youtrack list ;)

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 06, 2012 @ 00:03
    Anthony Dang
    0

    Patch will be in the next version of ublogsy

     

Please Sign in or register to post replies

Write your reply to:

Draft