Hello,
I created the following Macro to generate data from an excel file to an Outlook template. It takes the info from predetermined cells in the workbook. I works great to populate one email template but I would like to be able to populate multiple email templates from multiple rows. Can anyone show me how I can integrate Looping to my Macro? Thank you, Here is my Macro: Sub SendEmail() Dim olApp As Outlook.Application Set olApp = CreateObject("Outlook.Application") Dim olMail As Outlook.MailItem Set olMail = olApp.CreateItemFromTemplate("\\C:data for batch files\InfoIPTemplate.oft") LastNameMail = Range("AI2") FirstNameMail = Range("AH2") DirNumMail = Range("J2") PhoneNoMail = Range("K2") ShortIDMail = Range("B2") WOMail = Range("A2") ' To seperate PhoneNoMail in three different values NPA = Left(PhoneNoMail, 3) NXX_XXXX = Right(PhoneNoMail, 7) NXX = Left(NXX_XXXX, 3) Last4 = Right(NXX_XXXX, 4) olMail.To = LastNameMail & " " & FirstNameMail olMail.Subject = Replace(olMail.Subject, "ShortID_replace", ShortIDMail) olMail.Subject = Replace(olMail.Subject, "WO_replace", WOMail) olMail.HTMLBody = Replace(olMail.HTMLBody, "LastName_replace", LastNameMail) olMail.HTMLBody = Replace(olMail.HTMLBody, "FirstName_replace", FirstNameMail) olMail.HTMLBody = Replace(olMail.HTMLBody, "DirNum_replace", DirNumMail) olMail.HTMLBody = Replace(olMail.HTMLBody, "PhoneNo_replace", NPA & " " & NXX & "-" & Last4) olMail.HTMLBody = Replace(olMail.HTMLBody, "ShortID_replace", ShortIDMail) olMail.Display 'olMail.Send End Sub -- 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.