title: Error Excel Macro send email code of worksheet
body: <p>Basically, I want to send an email after I submit a macro button on the Excel worksheet. It will then send an email of the current worksheet to one of my email addresses.</p>
  
  <p>I tried researching to see if this was a bit of old code but no luck</p>
  
  <pre><code>Public Sub Export()
  
      a = MsgBox("Are you sure you want to save &amp; submit the report?", vbYesNo + vbQuestion)
  
      If a = vbYes Then
  
          Dim OutApp As Object
          Dim OutMail As Object
          Dim sTo As String: sTo = "health-safety@example.com"
  
          With Application
              .ScreenUpdating = False
              .EnableEvents = False
          End With
  
          Set OutApp = CreateObject("Outlook.Application")
          Set OutMail = OutApp.CreateItem(0)
  
          If Dir("\\dpfbhfap003\DP-CLD-Shares\CLD-Health and Safety\", vbDirectory) = "" Then
              ThisWorkbook.SaveAs "C:\Users\" &amp; Environ("UserName") &amp; "\Desktop\FARA - " &amp; shtAssess.Range("sLoc") &amp; " - " &amp; Format(shtAssess.Range("sDate"), "yyyymmdd") &amp; ".xlsm"
  
              On Error Resume Next
                  With OutMail
                      .To = sTo
                      .CC = ""
                      .BCC = ""
                      .Subject = ThisWorkbook.Name
                      .Body = "User did not have access to the ""\\dpfbhfap003\DP-CLD-Shares\CLD-Health and Safety\02_FARA\"" folder when exporting the file, so was unable to save a copy there."
                      .Attachments.Add ThisWorkbook.FullName
                      .Send
  '                    .Display
                  End With
              On Error GoTo 0
  
          Else
              ThisWorkbook.SaveAs "\\dpfbhfap003\DP-CLD-Shares\CLD-Health and Safety\02_FARA\FARA - " &amp; shtAssess.Range("sLoc") &amp; " - " &amp; Format(shtAssess.Range("sDate"), "yyyymmdd") &amp; ".xlsm"
  
              On Error Resume Next
                  With OutMail
                      .To = sTo
                      .CC = ""
                      .BCC = ""
                      .Subject = ThisWorkbook.Name
                      .Body = ""
                      .Attachments.Add ThisWorkbook.FullName
                      .Send
          '            .Display
                  End With
              On Error GoTo 0
          End If
  
          Set OutMail = Nothing
          Set OutApp = Nothing
  
          With Application
              .ScreenUpdating = True
              .EnableEvents = True
          End With
  
          a = MsgBox("Report has been successfully saved and emailed.", vbOKOnly + vbInformation, "Complete")
  
      End If
  
  End Sub
  </code></pre>
  
  <p>comes up saying </p>
  
  <blockquote>
    <p>"Run-time error '425'" ActiveX component can't create object </p>
  </blockquote>
  
  <p>and then it highlights this code  </p>
  
  <pre><code>Set OutApp = CreateObject("Outlook.Application")
  </code></pre>