PDA

View Full Version : Today() to send email.



VNouBA
06-27-2012, 11:22 AM
Good evening,
I am looking for a VB code online but with no explanation and no success.

I have a date in my worksheet (Column C); usually this date is a future date. I need a code that when that date is the present date it will send me an email with the following:

If date is today then send email:

Subject = File number “Range(Cells(Target.Row, 1)”

Note: The “Range(Cells(Target.Row, 1)” will trigger what is in my Column A vs. that date that is triggered and add it after File number.

Example: If C5 is Totay() and A5 = W123-123456 then Subject will be File number W1234-123456

Message: “File number “Range(Cells(Target.Row, 1)” will be taken off the system at 02:00 PM.”

Note: The “Range(Cells(Target.Row, 1)” will trigger what is in my Column A vs. that date that is triggered and add it after File number.

Nothing online that I have found…

Thank you so much for all you geniuses :D

CatDaddy
06-27-2012, 01:33 PM
If CDate(Range(target.row,3).Text) = Today Then

VNouBA
06-28-2012, 11:12 AM
If CDate(Range(target.row,3).Text) = Today Then


How would I continue the rest. If someone would have a link so I can get an idea please let me know I will also do my research.

Thank you so much

CatDaddy
06-28-2012, 11:30 AM
http://www.ozgrid.com/VBA/send-email.htm

VNouBA
06-28-2012, 12:05 PM
Ok I have figured out from that site, works like a charm now to tweek it to do the following:


Sub Mail_small_Text_Outlook()
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)


strbody = "Project number "" will expire today at 02:00PM"
'strbody = Needs to look in Column A vs. the row with the date of today and insert it in the "" section
' Example: If A5 = 1234 then strbody = "Project number 1234 will expire today at 02:00PM"

On Error Resume Next
With OutMail
.To = "my-email"
.cc = ""
.BCC = ""
.Subject = "Project number """
'.subject = Needs to look in Column A vs. the row with the date of today and insert it in the "" section
' Example: If A5 = 1234 then .Subject = "Project number 1234"
.Body = strbody
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing

End Sub



In my column C, as mentionned above, I have future dates and I need it to send if the date turn today()...

Example: User adds 2012/06/28 <---- then it will send an email. User adds 2012/06/30 <---- Then it will only send in two days.

Is this possible?