Hi Code Champs,
Below is the code to send emails through a selection in Excel as per http://www.rondebruin.nl/win/s1/outlook/bmail3.htm.
The likes of To, CC, subject line are hardcoded in the code.
However, I do not want this hardcoded. Instead, if I update column A1,B1 and C1 with the details of TO, CC and Subject, this would solve my purpose.
Can you please assist.
Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()
'Working in Excel 2002-2013
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 = "This is a test mail."
With .Item
.To = "abs@abc.com"
.CC = ""
.BCC = ""
.Subject = "My subject"
.Send
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
Bookmarks