The purpose of this macro is to send an email when an X (used to denote a failed product) is placed in the O column, I have played around with several different ideas, but have yet to have any success. Here is a copy of the code, any help is appreciated!
Private Sub Before_Close(ws As Worksheet, Cancel As Boolean)
ws.Cells(1, 7) = 0
Dim OutApp As Object
Dim OutMail As Object
Dim n As Integer
n = 7
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
While (n < 50)
If Worksheets("Areas Changed").Cells(n, 15) = "X" Then
.To = "jake.noble@roush.com"
.CC = ""
.BCC = ""
.Subject = "Engineering Change Altered Areas"
.Body = "The design for " & ws.Cells(3, 3) & " RMCC " & ws.Cells(4, 3) & " has failed checking."
ThisWorkbook.Save
.Attachments.Add ThisWorkbook.FullName
GoTo endSub
Else
n 1 = n
End If
LOOP
On Error GoTo failSection
.Send
End With
If (0) Then
failSection:
MsgBox ("Could not send email to Processing. Please check your internet connection and try again.")
ws.Cells(1, 7) = 1
End If
Set OutMail = Nothing
Set OutApp = Nothing
endSub:
End Sub
Bookmarks