Hi All,
I found the below code here, and it works as It should very well,
I was hoping someone might be able to modify this if possible please, I have applied this macro to a button press, but I would like the sender to be able to edit the body of the email text, via a message box or something?
And then have the option to send or cancel,
I'd really appreciate any help,
Thanks,
I found the below code here, and it works as It should very well,
I was hoping someone might be able to modify this if possible please, I have applied this macro to a button press, but I would like the sender to be able to edit the body of the email text, via a message box or something?
And then have the option to send or cancel,
I'd really appreciate any help,
Thanks,
VBA Code:
Sub Mail_workbook_Outlook_2()
'Working in Excel 2000-2016
'Mail a copy of the ActiveWorkbook with another file name
'For Tips see: https://jkp-ads.com/rdb/win/winmail/Outlook/tips.htm
Dim wb1 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim OutApp As Object
Dim OutMail As Object
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set wb1 = ActiveWorkbook
'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))
wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "Joe@live.com"
.CC = ""
.BCC = ""
.Subject = "BEV TT Pick Request"
.Body = "Please find our request attached"
.Attachments.Add TempFilePath & TempFileName & FileExtStr
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
'Delete the file
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub