Good Morning
I use this code to email a workbook daily,, is there a way to prevent another person sending the email ifs already been sent
Sub Mail_workbook()
Dim wb1 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim OutApp As Object
Dim OutMail As Object
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set wb1 = ActiveWorkbook
TempFilePath = Environ$("temp") & "\"
TempFileName = wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm")
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))
wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = ""
.CC = ""
.BCC = ""
.Subject = ""
.Body = "Good Afternoon" & vbNewLine & vbNewLine & _
" " & vbNewLine & vbNewLine & _
"Please find attached the Daily Compliance Report from; " & Sheet3.Range("O1") & vbNewLine & _
" " & vbNewLine & _
"Best Regards"
.Attachments.Add TempFilePath & TempFileName & FileExtStr
.Send
End With
On Error GoTo 0
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ThisWorkbook.Close SaveChanges:=True
End Sub
Many thansk
#
Bookmarks