0

I have the below code and it will open the email with the relevant details however the workbook is not attaching itself - cannot see why (being a newbie!)

Also is there a way of attaching a signature to the email? I'm using the newest version of the MS applications so not sure if this has any issues

Sub Email_workbook() Dim OutApp As Object Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
    .to = "pknight@xxxx.com"
    .CC = ""
    .BCC = ""
    .Subject = "Daily UK Orders Report"
    .Body = "Good afternoon, " & vbNewLine & vbNewLine & _
    "Please see the attached report for today's UK orders" & vbNewLine & _
    "Kind regards"
    .Attachments.Add ActiveWorkbook.Daily_UK_Orders_Report.xlsm
    .display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

End Sub

Thanks for your help

Phill

Phill Knight
  • 27
  • 1
  • 3
  • Remove On Error Resume Next (and the matching On Error GoTo 0) to see the error. Since you are now the programmer for this code, do not put these lines back. Update your question with the error if you cannot now fix it yourself. – niton Mar 24 '17 at 11:24
  • Thanks Niton, the issue turned out to be the active workbook name. Adjusted and all went through fine. – Phill Knight Mar 24 '17 at 11:33
  • Great. The norm is one question per post on this Q & A. It is easier for future searchers to find a subject of interest and you can accept answers from different people. You are overwriting your signature. Duplicate of http://stackoverflow.com/questions/8994116/how-to-add-default-signature-in-outlook – niton Mar 24 '17 at 11:56
  • Apologies for that Niton – Phill Knight Mar 25 '17 at 17:01

0 Answers0