title: Serilog Email Sink to use for sending email via Office 365
body: <p>I am trying to use Serilog's Email sink as part of simple console application.
  This application has very short lifetime: it checks DB and updates subscribers with a new data. I want to send an email if error happens.</p>
  
  <p>The problem is that if I don't put Thread.Sleep at the end of the app, emails are not sent.</p>
  
  <p>Is there any way to purge email queue and force email to be sent asap?</p>
  
  <p>My code is:</p>
  
  <pre><code>    Log.Logger = new LoggerConfiguration()
          .WriteTo.ColoredConsole()
          .WriteTo.EventLog("LOGSOURCE", restrictedToMinimumLevel: LogEventLevel.Warning)
          .WriteTo.Email(connectionInfo: new EmailConnectionInfo()
          {
              EmailSubject = "App error",
              ToEmail = "support@company.com",
              MailServer = "smtp.office365.com",
              NetworkCredentials = new NetworkCredential("sender@company.com", "Password"),
              Port = 587,
              FromEmail = "sender@company.com", 
              EnableSsl = false
  
          },
          batchPostingLimit: 1,
          restrictedToMinimumLevel: LogEventLevel.Error)
          .CreateLogger();
  
  Log.Error("Error message");
  </code></pre>
  
  <p>Any help is appreciated</p>