Hi @sintek
So the code you provided works perfectly, but i am still stuck in an infinite loop and can't figure out why.
Below is the final code(with the loop error) if anyone is interested.
The code seems to never stop running and if i hit ESC then it debugs to this part :
If cell.Value = "YES" Then
Any ideas?
Final Code(with loop error) :
Sub Approval_Mail()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim File As Object, Path As String
Path = "C:\Users\Andreaas\Desktop\Orders\" ' ! change to path that houses the files....
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
With CreateObject("Outlook.Application").CreateItem(0)
For Each cell In Worksheets("Data Input").Columns("Q").Cells
Set OutMail = OutApp.CreateItem(0)
If cell.Value = "YES" Then
With OutMail
.To = Worksheets("Data Input").Range("A55").Value & ";" & Worksheets("Data Input").Range("A54").Value
.Subject = Cells(cell.Row, "Q").Offset(-1, -1).Value & " " _
& Cells(cell.Row, "Q").Offset(0, -1).Value & " \ " _
& Cells(cell.Row, "Q").Offset(-1, -13).Value & " " _
& Cells(cell.Row, "Q").Offset(0, -13).Value
.Body = "Good Day" & " " & " Mr. " & Application.UserName & vbNewLine & vbNewLine & _
"Please see below and attached for your approval." & vbNewLine & "----------------------------------------------------------------------" & vbNewLine _
& Cells(cell.Row, "Q").Offset(-1, -13).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -13).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -12).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -12).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -11).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -11).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -10).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -10).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -9).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -9).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -8).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -8).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -7).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -7).Value _
& vbNewLine & vbNewLine & Cells(cell.Row, "Q").Offset(-1, -2).Value & " --> " & Cells(cell.Row, "Q").Offset(0, -2).Value _
& vbNewLine & "----------------------------------------------------------------------" & vbNewLine & "Thank You."
.Display
For Each File In CreateObject("Scripting.filesystemobject").getfolder(Path).Files
If File.Name Like "*1419*.pdf" Or File.Name Like "*1419*.x*" Then .Attachments.Add (File)
Next File
End With
Bookmarks