Hi, Hari,
right now I´m facing the fact that the macro that worked on the old file doesn´t create a mail on my system after I adapted it for the changes. Could you please check on your system if it´s working?
Sub Notify_121204()
Dim WS As Worksheet, rngArea As Range, rngCell As Range
Dim OutApp As Object, OutMail As Object
Dim Msg As String
Set WS = ThisWorkbook.Sheets("Hold-Data")
With WS
If .AutoFilterMode Then
.Range("A1:R1").AutoFilter
.Range("A1:R1").AutoFilter Field:=17, Criteria1:="0-15days"
Else
.Range("A1:R1").AutoFilter Field:=17, Criteria1:="0-15days"
End If
End With
On Error Resume Next
Set rngArea = WS.Range(WS.Cells(2, 17), WS.Cells(WS.Cells(Rows.Count, 17).End(xlUp).Row, 17)).SpecialCells(xlCellTypeVisible)
If rngArea Is Nothing Then Exit Sub
On Error GoTo 0
Set OutApp = CreateObject("Outlook.Application")
For Each rngCell In rngArea
If Len(WS.Cells(rngCell.Row, "T").Value) = 0 Then
Msg = "Dear Sir/Madam" & Chr(13) & Chr(13)
Msg = Msg & "Kindly provide the following clarification/ input required that we came across while processing your claim." & vbCrLf
Msg = Msg & "We would need your inputs to proceed further on processing of this claim." & vbCrLf & vbCrLf & _
"Vendor Claim Details: Document No./ Ref No. " & WS.Cells(rngCell.Row, "A") '<--- this is just a guess from my side
Msg = Msg & " [ having Invoice No. " & WS.Cells(rngCell.Row, "C").Value & " ] "
Msg = Msg & "of Vendor code " & WS.Cells(rngCell.Row, "D").Value & " of Vendor Name: " & WS.Cells(rngCell.Row, "E").Value & vbCrLf & vbCrLf
Msg = Msg & "Reason for Holding " & WS.Cells(rngCell.Row, "N").Value & vbCrLf & "Kindly attach the finance head approval for releasing the payment."
Msg = Msg & Chr(13) & Chr(13) & "*************************************************************************** **********"
Msg = Msg & Chr(13) & "If the Hold document is not resolved within 15 days from hold date the claim will be REJECTED."
Msg = Msg & Chr(13) & "*************************************************************************** **********"
Msg = Msg & Chr(13) & Chr(13) & "For further clarification please feel free to conduct us"
Msg = Msg & Chr(13) & Chr(13) & "Regards, " & vbCrLf & "Team"
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = WS.Cells(rngCell.Row, "J").Value
.CC = WS.Cells(rngCell.Row, "R").Value
.BCC = ""
.Subject = "Your Bills on HOLD"
.Body = Msg
.Send
End With
Set OutMail = Nothing
WS.Cells(rngCell.Row, "T").Value = WS.Cells(rngCell.Row, "P").Value
End If
Next rngCell
End Sub
Ciao,
Holger
Bookmarks