Good afternoon,
Hoping to get some help on this one.
I have a file that has a list of jobs, my boss will then put a % to each one of these jobs in E starting from E6.
Once that percentage hits 100%, I would like it to send an email to our billing person, that says something along the lines of:
"Hey, Job number B6, D6 is complete, please bill out. "
Then once its billed Mark P6 with "sent" so that it doesnt send multi emails for the same job.
Heres what I have so far, it does not work.
Any help would be appreciated!
Hoping to get some help on this one.
I have a file that has a list of jobs, my boss will then put a % to each one of these jobs in E starting from E6.
Once that percentage hits 100%, I would like it to send an email to our billing person, that says something along the lines of:
"Hey, Job number B6, D6 is complete, please bill out. "
Then once its billed Mark P6 with "sent" so that it doesnt send multi emails for the same job.
Heres what I have so far, it does not work.
VBA Code:
Option Explicit
Sub CompleteProjectEmail()
Dim i As Long
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim Rng As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error GoTo Emailerror
Set Rng = Range("E" & Cells(ActiveSheet.Rows.Count, "E6").End(xlUp).Row)
For i = Rng.Cells.Count To 1 Step -1
If Rng(i).Value = "100%" Then
strbody = "Hey Everyone" & "<br>" & "<br>" & _
"Job Number" & ActiveSheet.Range("B" & target.Row)& ActiveSheet.Range("D" & target.Row)& "was just marked 100%, Please start the billing process for this project." & "<br><br>"
On Error Resume Next
With OutMail
.To = "Email"
' .cc = ""
' .Bcc = ""
.Subject = "Complete Job - " & Range("B" & target.Row)
.htmlBody = strbody
'You can add a file like this
' .Attachments.Add (Range("J" & target.Row))
'.Attachments.Add (Range("K" & target.Row))
.send 'or use .send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Else
End If
Exit Sub
Emailerror:
Exit Sub
Next i
End Sub
Any help would be appreciated!