I have an excel doc that people in my department use to send mass emails. To monitor who is emailed monthly, I want to have it set up to email me a copy of the file with data without the user having to save a copy of the file. Currently, I am emailed the excel doc with no data on it. I tried to record a macro using the share feature in Excel. When I do this, macro just says
Application.Dialogs(xlDialogSendMail).Show
This shows the email along with the file with data attached. Now would like to autopopulate my email information and then have the file with data emailed to me. Does anyone know how to do that with VBA? BTW, I have to use late binding for this process. My current code that sends a copy of the file without data is below.
'Create an object for Outlook
Set OutlookApp = CreateObject("Outlook.Application")
'Create an object for the email
Set OutgoingEmail = OutlookApp.CreateItem(0)
'Turns off error handling (stops the "someone is trying to send an email" message)
On Error Resume Next
With OutgoingEmail
.to = "MyWorkEmail@Workemail.com"
'.CC =
'.BCC = ""
.Subject = NumberofPPL & " " & StaffBadge & " Mass Email Attempt"
.Body = NumberofPPL
.Attachments.Add (file)
.Send
End With
Set OutgoingEmail = Nothing
Set OutlookApp = Nothing