Sub test() Dim mailrng As Range Dim cl As Range Dim fl_path As String
Set mailrng = Sheets("Master").Range("d4:d5") For Each cl In mailrng ThisWorkbook.Sheets(cl.Offset(0, -2).Value).Copy fl_path = "C:\Documents and Settings\Ashish Koul\Desktop\sample files\" & cl.Offset(0, -2).Value & ".xlsx" On Error Resume Next Kill fl_path On Error GoTo 0 ActiveWorkbook.SaveAs fl_path ActiveWorkbook.Close Call sendmail(cl.Value, cl.Offset(0, 1).Value, cl.Offset(0, 2).Value, cl.Offset(0, -2).Value, fl_path) Next End Sub Sub sendmail(mailid As String, startdt As Date, enddate As Date, nm As String, flpath As String) Dim OutApp As Object Dim OutMail As Object Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .to = mailid .Subject = "Attendance from " & startdt & " to " & enddate .Body = "Dear " & nm & "," & vbNewLine & vbNewLine & "Please find attachment" & vbNewLine & vbNewLine & "Thank you" .Attachments.Add flpath .display 'or use .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub *make sure sheet name and name in table should match* On Sat, Jan 25, 2014 at 6:26 PM, Abhishek Jain <abhishek....@gmail.com>wrote: > Friends, > > A friend of mine needs to send attendance of employees to their email ids > and he wants a worksheet automated to do that function as doing it manually > for 400 employees is a bit exhausting task. A sample is attached herewith > for understanding. What I need is: > > > A VBA to use Microsoft Outlook or Outlook Express to send individual > emails to email ids given in master sheet. > > All emails would have a common subject, message, etc. but with a > different attachment for all employees. > > The attachment with emails would be the sheet marked for each employee > with their names. > > Any and all help will be appreciated. > > Thanks & regards, > > Abhishek > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It's > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/groups/opt_out. > -- *Regards* *Ashish Koul* *Visit* http://www.excelvbamacros.in Like Us on Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297> Join Us on Facebook <http://www.facebook.com/groups/163491717053198/> P Before printing, think about the environment. -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It's =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.