| |
rzarector
Posts: 2
Score: 0
Joined: 5/19/2008
Status: offline
|
Good Morning Hopefully this doesnt sound to complicated I got most of what I wanna do in the script down. I am trying to write a script that takes an excel file populates the body of an email and mails it off. The catch is I want the body of the email in a text file so that it is easily edited when needed. So far I have this that works 100%. I want to move the body from the vbscript to its own text file. Set WSHShell = WScript.CreateObject("WScript.Shell") Set appOutl = Wscript.CreateObject("Outlook.Application") Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open ("c:\newstudent.xls") Dim UserName, Advisor, UserEmail, AdvisorEmail Do Until objExcel.Cells(intRow,1).Value = "" Username = objExcel.Cells(intRow, 1).Value Advisor = objExcel.Cells(intRow, 2).Value UserEmail = objExcel.Cells(intRow, 3).Value AdvisorEmail = objExcel.Cells(intRow, 4).Value Set fso = CreateObject("Scripting.FileSystemObject") Set theFile=fso.CreateTextFile ("C:\Email.htm", vbTrue) theFile.WriteLine "<HTML>" theFile.WriteLine "<BODY>" theFile.WriteLine "Hi " &Username& "," theFile.WriteLine "<br><br>" theFile.WriteLine "This message is to confirm that your 2009 Advisor will be " &Advisor& " blah blah blah is part of the computer science department within xyz university. As a Counselee, you will be responsible for scheduling some time to work with your Counselor on future goal planning after reviewing blah blah blah." theFile.WriteLine "</BODY>" theFile.WriteLine "</HTML>" theFile.Close Set f = fso.OpenTextFile("C:\Email.htm",1) MyHTML = f.ReadAll f.Close Set maiMail = appOutl.CreateItem(0) maiMail.To = (objExcel.Cells(intRow, 2).Value) maiMail.Cc = (objExcel.Cells(intRow, 4).Value) maiMail.Subject = "Counselor Assignment" maiMail.HTMLBody = MyHTML maiMail.Display intRow = intRow + 1 Loop objExcel.Quit Set appOutl = Nothing Set maiMail = Nothing Set recMessage = Nothing
< Message edited by rzarector -- 5/19/2008 5:33:24 AM >
|
|