1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

sending an email using Gmail from MS access 2007

Discussion in 'Business Applications' started by Bingel, Dec 16, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. Bingel

    Bingel Thread Starter

    Joined:
    Dec 16, 2009
    Messages:
    3
    hello
    i'm trying to send an email from access using my gmail account, i founded a code in the net, that work perfectly but it doesn't tell you how to add an attachment...
    i tried several versions but i think i have a syntax error...

    can someone please tell what is the right form of adding an attachment?
    i bolded the specific line...

    thanks
    ben

    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 protected]"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "###"
    .Update
    End With
    ' build email parts

    With cdomsg
    .To = "[email protected]"

    .From = "[email protected]"
    .Subject = "the email subject"
    .attachments.Add "C:\My Documents\customer_Q2.xls"
    .TextBody = "read attachment"
    .Send
    End With
    Set cdomsg = Nothing
     
  2. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    Bingel, welcome to the Forum.
    I have found this piece of code for you to try.

    .Attachments.Add "c:\Service Report 1234", olByValue, , "Service Report"

    Substitute your xls doc for the one in the example.
     
  3. Bingel

    Bingel Thread Starter

    Joined:
    Dec 16, 2009
    Messages:
    3
    thanks for the fast replay
    i tried using the code but it didn't work.. :(
    i think this piece of code would work if i were using Outlook
    i don't know why it doesn't work when i'm trying to send it from Gmail
    if you have any ideas, i'll be happy to hear
    thanks
     
  4. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    Well, I have found this version that looks promising

    .Addattachment "C:\My Documents\customer_Q2.xls"

    I have just successfully sent an attachment using that method.
    or you can use

    Dim attach As String
    attach = "C:\My Documents\customer_Q2.xls"
    .Addattachment attach
     
  5. Bingel

    Bingel Thread Starter

    Joined:
    Dec 16, 2009
    Messages:
    3
    i'm ****ing speechless
    it's working !! :) :)

    thank you so very much

    you made my day

    really,
    i was trying to solve this almost for 2 days, and now i can uninstall outlook :)

    thanks
    Bingel
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/885962