Avatar of eossma
eossma
 asked on

Use CDO to send Email from Access

I asked a similar question not long ago and received what seemed to be an excellent. I was apparently overconfident in my abilities and don't know how to apply the code:

https://www.experts-exchange.com/questions/28635796/MS-Access-Send-Mail-script-via-Gmail.html?anchorAnswerId=40665760#a40665760

Could someone take a peek and assist me through this?  I'm on a network that uses Gmail.
Microsoft Access

Avatar of undefined
Last Comment
Joe Howard

8/22/2022 - Mon
gplana

Here is the information about how to configure gmail smtp settings:
http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm

So try something like this:

strTo = "destination@email.here" ' You should put the email destination address here
strFrom = "your@email.here" ' You should put your own gmail email address here
strSubject = "My Subject" 'You should put the subject of email here
strBody = "The text of the e-mail" 'You should put the text of the email here
strServer = "smtp.gmail.com" ' The smtp gmail server here
intPort = 466 ' The SSL port (SSL is required for sending emails using gmail)
strUsername = strFrom 'The username should be the same as your gmail email address
strPassword = "Put the password of your gmail account here"
intSentUsing = 2 ' Use SMTP over network
intAuthenticate = 1 ' Basic Authentication
blnUseSSL = true

bOk = SendEmail(strTo, strFrom, strCC, strBCC, strSubject, strBody, strServer, intPort, strUsername, strPassword, intSentUsing, intAuthenticate, blnUseSSL)

if not bOk then
   MsgBox("Error","Error sending email")
end if

Open in new window


If something is wrong maybe you can debug inside the function and see what is happening.

Hope this helps. Regards.
ASKER CERTIFIED SOLUTION
Joe Howard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck