erutherford
Active Member
- Joined
- Dec 19, 2016
- Messages
- 453
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>
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>