kltinaheart
New Member
- Joined
- Apr 20, 2018
- Messages
- 14
Im so close!
well kind of. Im a beginner and im trying to figure out how to Loop through ranges.
So, i have an excel sheet and i want to send a series of emails once a week.
So i currently figured out how to send an email based off of 1 chosen row (below), it takes the email address, it takes the message, and the subject!
what i want is to take the idea and make it depend on a time frame.
So lets say in Cell J, i make an If that results in a Yes No (If Date range is within 7 days of today, give me a yes)
I want the program to loop through the rows and take all of the "YES" cells and email out the associated row info into different emails.
(If J says Yes, email all the below)
Help me obi won kenobi, you're my only hope.
well kind of. Im a beginner and im trying to figure out how to Loop through ranges.
So, i have an excel sheet and i want to send a series of emails once a week.
So i currently figured out how to send an email based off of 1 chosen row (below), it takes the email address, it takes the message, and the subject!
what i want is to take the idea and make it depend on a time frame.
So lets say in Cell J, i make an If that results in a Yes No (If Date range is within 7 days of today, give me a yes)
I want the program to loop through the rows and take all of the "YES" cells and email out the associated row info into different emails.
(If J says Yes, email all the below)
Code:
Sub Email_PO()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim sTO As String, sSubj As String
sT0 = [M4]
sSubj = "PM Due - TESTER"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = " Hey " & Range("L4") & "," & vbNewLine & vbNewLine & _
"You have received a PO Trouble Ticket - " & vbNewLine & Range("K4") & vbNewLine & _
vbNewLine & "Please Email me immediately when it is finished!" & vbNewLine & vbNewLine & _
"Thanks again!"
On Error Resume Next
With OutMail
.To = sT0
.CC = ""
.BCC = ""
.Subject = sSubj
.Body = strbody
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Help me obi won kenobi, you're my only hope.