sending an email using Gmail from MS access 2007

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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

With cdomsg
.To = "###@gmail.com"

.From = "###@gmail.com"
.Subject = "the email subject"
.attachments.Add "C:\My Documents\customer_Q2.xls"
.TextBody = "read attachment"
.Send
End With
Set cdomsg = Nothing
 

OBP

Joined
Mar 8, 2005
Messages
19,895
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.
 

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
 

OBP

Joined
Mar 8, 2005
Messages
19,895
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
 

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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top