Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368

    sending gmail email through access

    Hi everyone,

    I'm trying to set up Access to automatically send emails from a gmail account. Found some code online but there was no support section for it. I think I may be missing a reference but I have CDO as well as the ActiveX references. The error I'm receiving and the code follows.

    Error: A problem occured while Microsoft Office Access was communicating with the OLE Server or ActiveX Control.



    Code:
    Code:
    Set cdomsg = CreateObject("CDO.message")
    With cdomsg.Configuration.Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
    .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "email@gmail.com"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
    .Update
    End With
    ' build email parts
    With cdomsg
    .To = "email@domain"
    .From = "username"
    .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
    Thanks

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    any ideas anyone?

  3. #3
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    See if this helps:

    Visual Basic Email via Gmail Tutorial

    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    thanks but that's where i got the code to begin with =P

  5. #5
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by TheShabz View Post
    thanks but that's where i got the code to begin with =P
    I use the the CDO/SMTP code, but not with gmail

    I will give it a try and see if I can get it to work.

  6. #6
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Well, I have tried the code in the link and it did not work. I have tried code use and it will not work with gmail.

    Did a little googling and this seems to be a common problem.

    I am going to see if I can configure outlook to send with gmail to see what setting are required.

  7. #7
    Matrix's Avatar
    Matrix is offline Admin
    Windows XP Access 2003
    Join Date
    Jan 2005
    Posts
    517
    Not sure about the code, but Gmail account must be configured before sending/receiving emails with a client software, it's in Gmail Settings.

  8. #8
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by Matrix View Post
    Not sure about the code, but Gmail account must be configured before sending/receiving emails with a client software, it's in Gmail Settings.
    That is what I have been reading.

    In gmail, I have turned on POP3, and IMAP. I am able to use my Plam Pre to send and recevie just fine.

    I have not figured out if there is some other setting in gmail to chnage.
    Last edited by HiTechCoach; 07-27-2010 at 07:01 PM.

  9. #9
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    well, heres a little more background. (sorry for the late reply as i didnt get any notifications about replies =/ )

    The purpose of this app is to notify myself and my partner when a data request is submitted. I am trying to develop a db that will act as sort of a help ticket system. the data request will be logged and an email will be sent with a cc to the user. this way we can keep everything tracked.

    The reason I am trying to use gmail is that Outlook security settings requires you to manually allow the sending of an email when its automated. Since my users are total IDtenT's, the only way I could convince them to go with it is if it was very very simple to use. having them click ok on Outlook to send an email isnt an option.

    I figured the Gmail approach would be the best option so I started searching for that. If you guys have any better ideas, I'm all ears.

  10. #10
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by TheShabz View Post
    well, heres a little more background. (sorry for the late reply as i didnt get any notifications about replies =/ )

    The purpose of this app is to notify myself and my partner when a data request is submitted. I am trying to develop a db that will act as sort of a help ticket system. the data request will be logged and an email will be sent with a cc to the user. this way we can keep everything tracked.

    The reason I am trying to use gmail is that Outlook security settings requires you to manually allow the sending of an email when its automated. Since my users are total IDtenT's, the only way I could convince them to go with it is if it was very very simple to use. having them click ok on Outlook to send an email isnt an option.

    I figured the Gmail approach would be the best option so I started searching for that. If you guys have any better ideas, I'm all ears.

    I current use this method a lot using my own domain/mail server to send information from my apps similar to what you are doing.. Just not with gmail.

  11. #11
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Try adding the following line to your code (to use SSL):

    Code:
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    Once I added that line, it worked for me.

  12. #12
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    that line is already there

  13. #13
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Hrm, so it is. . .

    Have you secured your G-Mail account (set it to require SSL)? If you haven't that could be the problem.

    Try this and see if it works. . . If it doesn't then it has to be some setting either on your computer/network or with your G-Mail account because it works for me.

  14. #14
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    after configuring Gmail, I a run-time error '-2147220973 cannot connect to server error. I then tried your mdb and got the same error. I'll try it again at home and see if i get the same issues. If not, it's my network and I'll have to run the hellish gauntlet that is IT access requests to get this working. I swear they've thought of every possible scenario to make life miserable.

  15. #15
    bdenton is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    10

    Adding attachments

    I am haveing difficulties adding the ability to add attachments. I have reviewed the Microsoft CDO for Exchange 2000 Library and have had no success. If anyone could assist in this regard it would be appreciated. I used the above example database (TheShabz_Email.mdb) as a base. Thanks B

    Quote Originally Posted by Rawb View Post
    Hrm, so it is. . .

    Have you secured your G-Mail account (set it to require SSL)? If you haven't that could be the problem.

    Try this and see if it works. . . If it doesn't then it has to be some setting either on your computer/network or with your G-Mail account because it works for me.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Email sending
    By Steven.Allman in forum Access
    Replies: 25
    Last Post: 06-21-2010, 09:37 AM
  2. Sending email
    By nashr1928 in forum Reports
    Replies: 8
    Last Post: 04-27-2010, 11:14 PM
  3. VB code for sending email through Option Group?
    By getdpt in forum Programming
    Replies: 0
    Last Post: 08-23-2009, 03:59 PM
  4. SENDING EMAIL MESSAGES DIRECTLY FROM ACCESS
    By Frenchos in forum Access
    Replies: 0
    Last Post: 07-20-2007, 12:51 AM
  5. Replies: 1
    Last Post: 03-09-2006, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums