anyway around this error?
of course, what error?
if I want to add a CC or BCC to the email how will I do that?
try like
Set r = msg.Recipients.Add(cel.Offset(, -cel.Column + 2) & "@test.com")
r.Type = 1
set r = msg.Recipients.Add("me@myserver.com") ' addd extra recipients like
r.type = 3 ' bcc
However if I click the "X" first then click on save excel just exists without generating an email. Is there a way to make it generate the email on both methods of exiting?
you did specify if it was saved, try
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set ol = GetObject(, "outlook.application") ' assumes outlook is already open
For Each cel In edited
Set msg = ol.CreateItem(0)
msg.Subject = "Your schedule has been updated."
' change the below line to your own email address for testing
Set r = msg.Recipients.Add(cel.Offset(, -cel.Column + 2) & "@test.com")
r.Type = 1
msg.Body = cel.End(xlUp) & vbNewLine & cel.End(xlUp).Offset(1) & vbNewLine & cel & vbNewLine & "rgds management"
msg.display ' look at your email before sending, remove when tested enough
' msg.send
Next
Set ol = Nothing
Set edited = Nothing
End Sub