Hi
I have some code (below) that I use to send a Named Range via the MailEnvelope function of Excel.
It was working for a while but now, when I run the macro to send the e-mail, everything works up to .Send. There are no crashes or error messages but it doesn't send. Before, you would see the e-mail appear in the Outbox and then it would be Sent. Now, it just bypasses that line in the code, continues but doesn't send.
Can anyone figure out what's going wrong?
I'm using Windows 10 and Office 365 (Outlook and Excel).
I can't for the life of me understand why it's worked previously and isn't anymore.
I have some code (below) that I use to send a Named Range via the MailEnvelope function of Excel.
It was working for a while but now, when I run the macro to send the e-mail, everything works up to .Send. There are no crashes or error messages but it doesn't send. Before, you would see the e-mail appear in the Outbox and then it would be Sent. Now, it just bypasses that line in the code, continues but doesn't send.
Can anyone figure out what's going wrong?
I'm using Windows 10 and Office 365 (Outlook and Excel).
I can't for the life of me understand why it's worked previously and isn't anymore.
Code:
Sub InterimReport_Send()
If ActiveSheet.Name = "Report" Then
ThisWorkbook.Save
Dim PreviousSelection As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
Set PreviousSelection = ActiveCell
ActiveSheet.Unprotect Password:="Report"
Range("Report_InsideBorders").Borders(xlInsideHorizontal).Weight = xlMedium
ActiveSheet.Protect Password:="Report"
On Error GoTo StopSend
Range("Report_MailRange").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope.Item
.To = "email@address.com"
.Subject = "Subject"
.Send
End With
ActiveWorkbook.EnvelopeVisible = False
StopSend:
ActiveSheet.Unprotect Password:="Report"
Range("Report_InsideBorders").Borders(xlInsideHorizontal).Weight = xlThin
ActiveSheet.Protect Password:="Report"
PreviousSelection.Select
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With
End If
End Sub