Results 1 to 3 of 3
  1. #1
    alyon is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    89

    smtp email code


    I'm trying to figure out a good code to use to send an email from Access 2007 through a smtp server. The email source I'm trying to use is godaddy, if that helps. All the codes I've found so far for smtp email, I change to fit our settings, and this error "A problem occured while Microsoft Office Access was communicating with the OLE server or ActiveX Control" always comes up. Also, all the smtp code doesn't show how to send a specific report, just file attachments from a root path. I know Outlook code, and to specify a certain report, and pdf, and whatnot... but outlook is not making anyone happy. Any help would be greatly appreciated.

    Thanks!
    alyon

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    This has code for Lotus Notes, maybe is adaptable http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

    Except with the SendObject method http://msdn.microsoft.com/en-us/libr...ffice.12).aspx, don't think can email the report directly, must email report output (PDF, Excel, RTF).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alyon is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    89
    Thanks for the reply, I couldn't get it to work.. So I ended up just going through a gmail account and used this code:
    Set objmessage = CreateObject("CDO.Message")
    myAttachment = "\\Attachment\Path.pdf "
    objmessage.Subject = "My Subject"
    objmessage.From = "me@email.com"
    objmessage.To = Me.txtOwnerEmail.Value
    objmessage.TextBody = "Body Message"
    objmessage.AddAttachment myAttachment
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
    objmessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    objmessage.Configuration.Fields.Update
    objmessage.SEND
    Set objmessage = Nothing

Please reply to this thread with any new information or opinions.

Similar Threads

  1. NO minimize button in Email Code
    By taimysho0 in forum Programming
    Replies: 1
    Last Post: 02-03-2012, 08:11 PM
  2. Email from Access 2003 with SMTP authentication
    By prstoessel in forum Programming
    Replies: 1
    Last Post: 12-16-2011, 12:07 AM
  3. VBA Code to report syntax errors via email
    By jazzkenney in forum Programming
    Replies: 6
    Last Post: 11-30-2011, 08:54 PM
  4. Windows 7 and smtp mail with Access 2003
    By mafhobb in forum Programming
    Replies: 1
    Last Post: 06-28-2010, 09:05 AM
  5. VB code for sending email through Option Group?
    By getdpt in forum Programming
    Replies: 0
    Last Post: 08-23-2009, 03:59 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