Automated emails based on date

erutherford

Active Member
Joined
Dec 19, 2016
Messages
458
Found tons of info on this, but this config might be out of my league. I was able to send and receive an email through excel with this code. Is it possible to do the following with this code. I am using Gmail as the provider. Most use outlook, but I don't.

Base on the date in column Q (365 days +1) an email is sent to that person (same verbiage to all that receive it)
Col A = First name
Col B = Last name
Col K = email Address

<code>
Sub gmail_send()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxx@xxxxx.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxxxxxxxxxxxx"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.xxxxxx.com"

.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is your annual reminder to update your TAN contact information" & vbNewLine & _
"Click here to review your information"

With iMsg
Set .Configuration = iConf
.To = "xxxx@xxxxxxxxx.com"
.cc = "xxxxxx@xxxxxxxx.com"
.BCC = ""
' Note: The reply address is not working if you use this Gmail example
' It will use your Gmail address automatic. But you can add this line
' to change the reply address .ReplyTo = "Reply@something.nl"
.From = """somebody"" <xxx@xxxxxxxxxxxxxxxxxx.com>"
.Subject = "TAN"
.TextBody = strbody
.send
End With

Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

End Sub
</code>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top