Private Sub CommandButton2_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("D").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "E").Value) = "ja" _
And LCase(Cells(cell.Row, "T").Text) = "0%" _
And LCase(Cells(cell.Row, "F").Value) <> "Inged." Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "jo.geuens@zf.com"
.Cc =
.Bcc = Cells(cell.Row, "Y") & ";" & Cells(cell.Row, "AA")
.Subject = "werkaanvraag "
.Body = "Er werd een nieuwe aanvraag ingediend door: " & Cells(cell.Row, "C").Value _
& vbNewLine & vbNewLine & _
"Prioriteit: " & Cells(cell.Row, "R").Value _
& vbNewLine & _
" NR: " & Cells(cell.Row, "B").Value _
& vbNewLine & _
"Voor Project: " & Cells(cell.Row, "G").Value _
& vbNewLine & _
"Werkaanvraag: " & Cells(cell.Row, "H").Value _
& vbNewLine & _
" Met: " & Cells(cell.Row, "I").Value & Cells(cell.Row, "J").Value _
& vbNewLine & vbNewLine & _
"Omschrijving: " & Cells(cell.Row, "K").Value _
& vbNewLine & _
" " & "Opmerking: " & Cells(cell.Row, "L").Value _
& vbNewLine & _
" " & "Opmerking aan : " & Cells(cell.Row, "X").Value _
& vbNewLine & _
" " & Cells(cell.Row, "AB").Value _
& vbNewLine & vbNewLine & _
"Groeten, "
.display
On Error GoTo 0
Cells(cell.Row, "F").Value = "Inged."
Cells(cell.Row, "T").Value = "1%"
End With
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
'ActiveSheet.Protect
End
Indienenaanvraag.Hide
Aanvraag.Hide
ActiveWorkbook.Save
' Application.Quit
'ActiveWorkbook.Close
End Sub