Link to home
Create AccountLog in
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.
Avatar of gplana
gplana
Flag of Spain image

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
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account