So I'm working on building a distribution list off of my schedule at work and I found some handy dandy vba code for outlook on youtube, but in the video he admits that his code will only look up for a specific range, and my list will change daily considering vacation time, sick time, etc. He then says, "So you'll have to figure a way around this."
From some of my previous projects, I figured I could just do a:
DoUntil IsEmpty.Activecell
. . . but as it appears in the below code, it's giving me a Sub or Function Not Defined error. I'm hoping it's just a simple fix as I'm trying to keep the code as simple as possible.
Sub SendEmail(what_address As String, subject_line As String, mail_body As String)
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.to = what_address
olMail.Subject = subject_line
olMail.body = mail_body
olMail.send
End Sub
Private Sub CommandButton1_Click()
'
'set starting point under header
row_number = 1
'
'run loop to send email to all identified recipients upon click
Do
DoUntil IsEmpty("A" & row_number)
row_number = row_number + 1
Call SendEmail(Sheet1.Range("A" & row_number), Sheet1.Range("B" & row_number), Sheet1.Range("C2"))
Loop
End Sub
Any help you could provide would be much oblidged.
Bookmarks