Sub ReturnByEmail()
Dim Msg, Style, Title, Help, Ctxt, Response, ReturnAddress 'define variables
ReturnAddress = "xxxx@xxxxx.xx.xx"
Msg = "Send completed forecasts to xxxxx? N.B. you may wish to foward a copy to your line manager."
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Monthly Monitoring Return" + " " + ThisWorkbook.Name ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes - email will be sent.
On Error GoTo ErrorHandler 'need to trap invalid email addresses or other mail failure
ActiveWorkbook.SendMail Recipients:=ReturnAddress, Subject:=Title, RETURNRECEIPT:=True
On Error GoTo 0
Msg = "Your email has been sent - and should appear in Outlook, Sent Items"
Style = vbOK + vbDefaultButton1 ' Define buttons.
Title = "Monthly Monitoring Return" + " " + ThisWorkbook.Name ' Define title.
Response = MsgBox(Msg, Style, Title)
Else ' User chose No.
End If
Exit Sub
ErrorHandler:
Msg = "Mail failure - is your mailbox too full? Try sending an email directly from outlook to " + ReturnAddress + " before reporting the fault"
Style = vbOK + vbDefaultButton1 ' Define buttons.
Title = "Monthly Monitoring Return" + " " + ThisWorkbook.Name ' Define title.
Response = MsgBox(Msg, Style, Title)
End Sub