Sub sendBook(ByVal theAddy As String, ByVal theBook As String, ByVal theType As String)
Dim wb As Workbook, wasOpen As Boolean
Dim olApp As Object, olMsg As Object
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next
wasOpen = True
Workbooks(Sheet1).Activate
If Err <> 0 Then
Set wb = Workbooks.Open("C:\Users\op936sp\Documents\ADMIN\Library\Library Check In-Check Out.xlsx")
wasOpen = False
Err.Clear
Else
Set wb = ActiveWorkbook
wb.Save
End If
Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)
With olMsg
.To = theAddy
.Subject = "Overdue library " & theType & " notice"
.HTMLbody = "Please return the overdue " & theType & " listed below to MS 56. If you would like to request an extension, please contact Stephanie Kutchinski at ext. 4686." & "<P><B><I>" & theBook & "</P></B></I>"
.Send
End With
If wasOpen = False Then
wb.Close True
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
Set olApp = Nothing
Set olMsg = Nothing
End Sub
Bookmarks