Question : Vbs/HTA to send email (Html) based on excel sheet

Hi Experts,

Can I please get some help on tmy below mentioned requirement.

We are looking for script which will read the date's from the excel sheet and capture the login ID's mentioned adjecnt to the date's and send a HTML formatted mail to those login ID.

Please do let me know if you require any details on the same.

format of excel sheet attached.

Attachments:
 
 

Answer : Vbs/HTA to send email (Html) based on excel sheet

Here is the modified script. You just need to change the dates in the script.


OPTION Explicit
Dim objExcel
Dim objWorkbook
Dim CurDate
Dim objEMail
Dim excelDate
Dim strDate
Dim strEMail
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
   ("C:\Tpxtracker.xls")

Dim StartDate
StartDate = CDate("01/14/2010")
Dim EndDate
EndDate = CDate("01/31/2010")

Dim intRow
intRow = 2
CurDate = Date()
'Wscript.Echo "Today's Date: " & CurDate
Do Until objExcel.Cells(intRow,9).Value = ""
   'Wscript.Echo "EMail: " & objExcel.Cells(intRow, 6).Value
   'Wscript.Echo "Date: " & objExcel.Cells(intRow, 9).Value
   excelDate = objExcel.Cells(intRow, 9).Value
   strEMail = objExcel.Cells(intRow, 6).Value
   If    StartDate <= excelDate And EndDate >= excelDate then
        Set objEmail = CreateObject("CDO.Message")
       objEmail.From = "[email protected]"
       objEmail.To = strEMail
       objEmail.Subject = "Welcome"
        objEmail.HTMLBody = "<b>Welcome to the Company.</b>"
       objEmail.Configuration.Fields.Item _
           ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
       objEmail.Configuration.Fields.Item _
           ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
               "smtpservername"
        objEmail.Configuration.Fields.Item _
           ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
       objEmail.Configuration.Fields.Update
       objEmail.Send
       Wscript.echo "Mail sent to " & strEMail
   End If
   intRow = intRow + 1
Loop

objExcel.Quit

Random Solutions  
 
programming4us programming4us