Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send email with attachement from Access using VBA and Mozilla

Status
Not open for further replies.

spitzmuller

Programmer
May 7, 2004
98
CH
Hi guys.

I am sure there's plenty of info out there, but the one I found didn't work for me, so a dare to ask here.

Can anyone point me in the right direction as to how to send an email over a mozilla thunderbird client using VBA in Access.

Thanks a lot
 
Have you tried the DoCmd.SendObject method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV, Thanks for your response

SendObject only allows to send Access Objects...

But I would like to automatically generate an email with a file on the harddrive attached to it. I need to send Reports as PDF, and I figured out how to generate the PDFs but can't seem to get the emailing part to work.

I tried

Call ShellExecute(hWnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL)

with stext being

mailto:simon.spitzmueller@gmx.ch?CC=simon.spitzmueller@gmx.ch&BCC=
simon.spitzmueller@gmx.ch&Subject=TestSubjekt&Body=Blablablablabla&Attach=
"File.PDF"

and it works... almost. The Email gets created but the attachement is missing. My standard mail client is Thunderbird!

Greets Simon



 
Hi.

Take a look at
It has neat code that allows you to gen and send an email with out having to care about what your e-mail software is.

Solved similar problems for me.

Thanks,
ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Thanks for the link, blorf

I'm using this code:

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "bla@bla.com"
objMessage.To = "blo@blo.com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\Test.pdf"
objMessage.Send

And I get a runtime-error on the Send command: "the sendusing configuration value is invalid"

I tried to set it to other values but no success. Any ideas?
 
Hi.

The CDO code requires that you specify the account information as well as the message.

Try adding the following just above the .send line. replace these with actual values

smtp.YourSMTP.com
YourAddress@blah.com
YourPassword

Remember this code is designed to create and send an e-mail with out utilizing your e-mail software, so you don't have to configure for use with Outlook or Express or anything else, just uses the internet connection.

Thanks,
ChaZ



objMessage.Configuration.Fields.Item _
(" = 2

objMessage.Configuration.Fields.Item _
(" = "smtp.YourSMTP.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
(" = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
(" = "YourAddress@blah.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
(" = "YourPassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
(" = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
(" = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
(" = 60

objMessage.Configuration.Fields.Update
/
Code:
There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Ooops, forgot.

You need these constants prior to creating the object.

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM


ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Thanks again for your response, blorf.

I was kind of hoping, using cdo would open the standart email client if all these smtp-parameters are not available. But after what you said, this is not the case I guess.

But I need the standard mail client to open and let the user modify the email before it is sent. The approach with 'mailto:...' and the ShellExecute that I mentioned earlier does a nice job, except that at least with Thunderbird, attachements are not interpreted. And that's exacly what I need.

Any other suggestions?? Thanks Simon
 
Sorry, I am not familiar with Thunderbird.

I will peek around though.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top