TempFilePath = Environ$("temp") & "\"
TempFileName = Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
If [f14].Value = "ENTER EMAIL ADDRESS" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.to = [i6].Value
.CC = [i10].Value
.BCC = ""
.Subject = "Incident Report"
.Body = "Incident Report Attached"
.Attachments.Add Destwb.FullName
.DISPLAY
End With
On Error GoTo 0
.Close savechanges:=False
End With
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
ActiveSheet.Protect
End With
Call data
Else
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.to = [i6].Value & ";" & [f14].Value
.CC = [i10].Value
.BCC = ""
.Subject = "Incident Report"
.Body = "Incident Report Attached"
.Attachments.Add Destwb.FullName
.DISPLAY
End With
On Error GoTo 0
.Close savechanges:=False
End With
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
ActiveSheet.Protect
End With
Call data
End If
End Sub
longwinded way of doing it but does the job....
Bookmarks