Anbuselvam K
Member
Hi
With the below code I am sending the email from outlook with the selected cells as an image.
In the subject as per code, today date is showing. Instead of today's date, I want to show the selected date through a filter.
Eg: If I filter 04-Feb-2020 then the subject should show 04-Feb-2020.
If I did not filter any dates, selecting and sending full month date then it should show "The report for the month of February 2020"
Please do the needful.
With the below code I am sending the email from outlook with the selected cells as an image.
In the subject as per code, today date is showing. Instead of today's date, I want to show the selected date through a filter.
Eg: If I filter 04-Feb-2020 then the subject should show 04-Feb-2020.
If I did not filter any dates, selecting and sending full month date then it should show "The report for the month of February 2020"
Please do the needful.
Code:
Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()
'Working in Excel 2002-2016
Dim Sendrng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Note: if the selection is one cell it will send the whole worksheet
Set Sendrng = Selection
'Create the mail and send it
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "Find below the pick-up log details"
With .Item
.To = "xxxxx@xxx.xxx" ' modify email-address as needed
.CC = ""
.BCC = ""
.Subject = "PICK-UP LOG Details " & Format(Date, "dd-mmm-yyyy")
.send
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
Attachments
Last edited by a moderator: