title: Send mail when Outlook is not already open
body: <p><strong>My situation:</strong></p>
  
  <p>I'm trying to send e-mails while Outlook is not open. This code will work if Outlook is running. If Outlook is closed the code will create a non-visible process that you can see running in Task Manager.</p>
  
  <p>The code encounters an error during the <code>.Send</code>. It returns runtime error 287.</p>
  
  <p>From my experience that are certain VBA methods that will only work when the object is either visible or active.</p>
  
  <p>My work around is to use <code>.Display(False)</code> before calling <code>.Send</code>.</p>
  
  <p>After calling <code>.Send</code> it immediately terminates the Outlook process. (Please point me to the right direction why.) Then the e-mail gets stuck in the Outbox.</p>
  
  <p>I have to apply another work around by calling another <code>CreateObject("Outlook.Application")</code> and either looping through the Outbox <code>While Outbox.Items.Count &gt; 0</code> </p>
  
  <p>or</p>
  
  <p>Looping through <code>SyncObjects</code> and manually calling <code>.Start</code> to run Send/Receive on the Outbox.</p>
  
  <p><strong>My question:</strong></p>
  
  <p>Is there a way to directly use the <code>.Send</code> method instead of using work arounds while also not having to open Outlook.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>Sub emailer()
  
  Dim OutApp As Object
  Dim OutMail As Object
  
  Set OutApp = CreateObject("Outlook.Application")
  Set OutMail = OutApp.CreateItem(0)
  
  With OutMail
      .to = "f@r.com"
      .CC = ""
      .BCC = ""
      .Subject = "This is the Subject line"
      .Body = "Hi there"
      .Send   'or use .Display
  End With
  
  Set OutMail = Nothing
  Set OutApp = Nothing
  
  End Sub
  </code></pre>