Good afternoon -
I know there are multiple threads surrounding this topic. I have tried to follow and apply the various notes. However, because I have ZERO programming/code writing experience, I am quickly overwhelmed. The code to use Gmail is working for me from the VBA screed (test run). Now, can anyone help add the required coding to run an existing query that updates my table AND then attach the updated table to send as an XLS attachment?
Second part to this, I need help "calling" the sub to run from the click of a designed button. Every time I try to send just the test e-mail, I get an error.
Here is the existing Gmail code:
Public Sub send_email()
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/con...smptserverport") = 465
.Item("http://schemas.microsoft.com/cdo/con...tpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/con...ion/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/con...nectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/con...n/sendusername") = "mygmail@gmail.com" 'I know this is my e-mail
.Item("http://schemas.microsoft.com/cdo/con...n/sendpassword") = "mypassword" 'I know this is my pw
.Update
End With
' build email parts
With cdomsg
.To = destination e-mail
.From = "mygmail@gmail.com"
.Subject = "the email subject"
.TextBody = "the full message body goes here. you may want to create a variable to hold the text"
.Send
End With
Set cdomsg = Nothing
End Sub