Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

sending an email using Gmail from MS access 2007


(!)

Bingel's Avatar
Bingel Bingel is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: Dec 2009
Experience: Beginner
16-Dec-2009, 03:56 AM #1
sending an email using Gmail from MS access 2007
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/con...tion/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/con...smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/con...tpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/con...ion/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/con...nectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/con...n/sendusername") = "###@gmail.com"
.Item("http://schemas.microsoft.com/cdo/con...n/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's Avatar
OBP OBP is offline OBP is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 18,668 posts.
 
Join Date: Mar 2005
Location: UK
16-Dec-2009, 08:52 AM #2
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's Avatar
Bingel Bingel is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: Dec 2009
Experience: Beginner
17-Dec-2009, 01:34 AM #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's Avatar
OBP OBP is offline OBP is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 18,668 posts.
 
Join Date: Mar 2005
Location: UK
17-Dec-2009, 08:06 AM #4
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's Avatar
Bingel Bingel is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: Dec 2009
Experience: Beginner
17-Dec-2009, 08:19 AM #5
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
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


Tags
access 2007, attaching files, email, syntax error, vba

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2