Link to home
Create AccountLog in
Avatar of 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:

Could someone take a peek and assist me through this?  I'm on a network that uses Gmail.
Avatar of gplana
Flag of Spain image

Here is the information about how to configure gmail smtp settings:

So try something like this:

strTo = "" ' You should put the email destination address here
strFrom = "" ' 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 = "" ' 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.
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

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