title: Send email automatically using outlook from excel
body: <p>I am trying to send an open workbook (Excel) every day at 5pm. Here is my code:</p>
  
  <p>I put this one in a module</p>
  
  <pre><code>Sub SendEmail()
  
      Dim OutApp As Object
      Dim OutMail As Object
      Set OutApp = CreateObject("Outlook.Application")
      Set OutMail = OutApp.CreateItem(0)
  
      With OutMail
          .To = "yourmail"
          .CC = ""
          .BCC = ""
          .Subject = "Report"
          .Body = "Hello!"
          .Attachments.Add ActiveWorkbook.FullName
  
          .Send
      End With
  
      Set OutMail = Nothing
      Set OutApp = Nothing
      Application.OnTime TimeValue("17:00:00"), "SendEmail"
  
  End Sub
  </code></pre>
  
  <p>and i put this one in ThisWorkbook</p>
  
  <pre><code>Sub Workbook_Open()
  
      Application.OnTime TimeValue("17:00:00"), "SendEmail"
  End Sub
  </code></pre>
  
  <p>My workbook is open all the time.
  I can't get the email, except I hit the run button in Excel. I want it do automatically everyday.</p>