PDA

View Full Version : email results



wilg
04-09-2011, 08:06 AM
Hi, have below code that i'm trying to modify to return results if it finds a date less than today. The results I want to put into the body of the email is...

First instance of date less than today would be column b
then specified results in same row in column J

The below code returns sesults in rows below where it found the instance of dates less than now.

Sub update()
Dim ReturnValue As Integer


ReturnValue = MsgBox("Would you like to send email to update results?", vbYesNoCancel, "")


Select Case ReturnValue
Case vbNo: Exit Sub
Case vbYes:

Call OpenOutlook
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = ""
Email_Send_From = ""
Email_Send_To = ""
Email_Cc = ""
Email_Bcc = ""
Email_Body = vbNewLine & ""
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
For i = 2 To 22



If Cells(4, i).Value <= Now() Then

Email_Body = Email_Body & vbNewLine & Format(Cells(4, i).Value, "dddd mmmm = ") & Cells(10, i).Value
End If

Next i

.Body = Email_Body




.send
End With

End Select