hi, how do i send email to the users using mt excel file automatically? i have the code i get from the net. but i dunno how to use. they gave me an error when it is at .send. do i have to configure anything? i jus paste the code in my excel. please help, i am new to vba. thanks
Code:
Sub Sendmail()
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
sTo = "[EMAIL="whcmelvin@email.com"]whcmelvin@email.com[/EMAIL]"
sCC = ""
sBCC = ""
sSubject = "Overdue"
strbody = "Good Morning" & vbNewLine & vbNewLine & _
"Here is a message"
With OutMail
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = sSubject
.Body = strbody
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sub CheckDue()
Dim rDates As Range, cl As Range
Set rDates = Sheet1.Range("a1", Range("a65536").End(xlUp))
For Each cl In rDates
If cl.Value >= Date Then
sTo = cl.Offset(0, 1).Value 'assumes addresses in Column B
Call Sendmail
End If
Next cl
End Sub