Sub SendEmailObligation() Application.DisplayAlerts = False Application.ScreenUpdating = False Workbooks("Auto Mail Schedule.xls").Activate Sheets("Client mail").Select For i = 2 To Range("a1").SpecialCells(xlCellTypeLastCell).Row AttachFileName1 = Cells(i, 5).Value & Cells(i, 6).Value AttachFileName2 = Cells(i, 5).Value & Cells(i, 7).Value If Dir(AttachFileName1) <> "" Then 'And Dir(AttachFileName2) <> "" Then ESubject = Cells(i, 3).Value & " Exchange Obligation Report for Delivery Date " & Format$(Date + 1, "MMMM dd, yyyy") & "." SendTo = Cells(i, 1).Value CCTo = Cells(i, 2).Value Ebody = "Dear Sir/Ma'am," & Chr(10) & Chr(10) & _ "Kindly find the attached exchange result for the day." & Chr(10) & Chr(10) & _ Chr(10) & Chr(10) & "The obligation reports are also attached herewith." _ & Chr(10) & Chr(10) & "Thanks & Regards," _ & Chr(10) & Chr(10) & "GMRETL Control Room" _ & Chr(10) & "New Shakti Bhawan,Opposite ATS complex" _ & Chr(10) & "IGIA New Delhi-110037 " _ & Chr(10) & "Phone: Off: 011-49883320,Fax: Off: 011-49882255/49883331 " _ Set App = CreateObject("Outlook.Application") Set Itm = App.CreateItem(0) With Itm .Subject = ESubject .To = SendTo .CC = CCTo .Body = Ebody .Attachments.Add (AttachFileName1) .Attachments.Add (AttachFileName2) ' Must be complete path .Save '.Send End With Set App = Nothing Set Itm = Nothing End If Next MsgBox ("All Clients mails Ready to be Sent!!! ") End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)