Send Email From Access Code (1 Viewer)

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
Hi, been Googling for a soilution but the answrs aren't very clear. Some say you don't need code, others there's a free trial ??
I'd like to launch this frmm a command button annd send a table

Looks like you use DoCmd.SendObject but exmple shows
Code:
DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _
  "Nancy Davolio; Andrew Fuller", "Joan Weber", , _
  "Current Spreadsheet of Employees", , False
Does it send a table called "Employees", but why in Excel Format? Or doesn't that matter?
But main problem is where are the email addresses?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:31
Joined
Feb 19, 2013
Messages
16,553
see this link about sendobject - you will see one of the paramters you supply is 'to'. In your example it is Nancy Davalio and Andrew Fuller (presumably the names in outlook contacts)


why excel format? format is up to you - but needs to be in a form the recipient can open
 

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
I'd seen that link, it was the confusing one!

Why the mention of Outlook? Is it not possible with Access only ?
 

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
Thank you, just downloading now.
 

neuroman9999

Member
Local time
Yesterday, 21:31
Joined
Aug 17, 2020
Messages
827
does CDO still even work? I'm sure it does, but that's been around for sooooo long.
 

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
I haven't been able to get it working as yet.
l was unable to send the email message(s).
Error # -2147220958
The pickup directory path is required and was not specified.

Whatever the pickup directory path is, there's no place to enter it and nothing about it in the Help file.
 

neuroman9999

Member
Local time
Yesterday, 21:31
Joined
Aug 17, 2020
Messages
827
Actually Kirk I have seen that error message before from someone else that used Collins code and tried to make it work and I believe I even downloaded at one point and tried to make it work but I don't think I got the same error it was another one. I'm not saying anything bad about Collins work it's simply that what you downloaded from him is extremely complex and there's so many variables more than likely it's not going to work perfect it needs to be tweaked.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:31
Joined
Aug 30, 2003
Messages
36,118
I haven't used Colin's code, but I can verify CDO still works fine.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:31
Joined
Aug 30, 2003
Messages
36,118
And maybe I should clarify that I'm sending out via an Exchange server. Can't answer for other configurations.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:31
Joined
Aug 30, 2003
Messages
36,118
No, I meant an on premises Exchange server, commonly used by businesses beyond a certain size, though perhaps hosted Exchange is becoming more common.
 

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
I've never heard of CDO until now and can't find why it's failing. But found another routine that opens the mail programme and sends command line parameters... mail programme opens with everything populated and you just need to click "Send". Probably good enough.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:31
Joined
Feb 28, 2001
Messages
27,001
CDO will send SMTP protocol directly from the PC with our without Outlook involved. I have used it that way.

The error you listed, -2147220958 , translates to 80040222. Here are some links to explain the error.



They both report the error as the same cause, the "Send Using" option is set wrong.
 

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
Many thanks, just about to try that.
Is it permissable to use that code in my db? Would I need anything additional to what's in Access itself?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:31
Joined
Feb 28, 2001
Messages
27,001
As long as you have the appropriate reference selected, you should be fine. It is called Microsoft CDO for Windows 2000, but don't let that date fool you. It still works in later versions of Windows and Access.
 

isladogs

MVP / VIP
Local time
Today, 02:31
Joined
Jan 14, 2017
Messages
18,186
Hi Kirk
The help file DOES describe the cause of that error together with the solution.

1599034346284.png

It also lists all other errors I've ever experienced in 20 years of using CDO together with the solution to each

Sorry to contradict Doc, but you do NOT need the Microsoft CDO for Windows 2000 reference as the functionality has been built in to Access for many years

PDF copy of help file attached
 

Attachments

  • EMailHelp.pdf
    464 KB · Views: 179

kirkm

Registered User.
Local time
Today, 15:31
Joined
Oct 30, 2008
Messages
1,257
My apologies Colin, I missed that because I looked with cntrl-f. Darn!
My other bug was using Port 115 instead of 25. I got that from Thunderbird settings but obviously wrong,
Why is it Network (SendUsing-2) if on a local machine? Just curious.
OK on the reference, I noticed it wasn't in the list.
 

vhung

Member
Local time
Yesterday, 19:31
Joined
Jul 8, 2020
Messages
235
Hi, been Googling for a soilution but the answrs aren't very clear. Some say you don't need code, others there's a free trial ??
I'd like to launch this frmm a command button annd send a table

Looks like you use DoCmd.SendObject but exmple shows
Code:
DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _
  "Nancy Davolio; Andrew Fuller", "Joan Weber", , _
  "Current Spreadsheet of Employees", , False
Does it send a table called "Employees", but why in Excel Format? Or doesn't that matter?
But main problem is where are the email addresses?
nice ;
send table to email thru msaccess that's greats
if codes is accurate would be helpful, any format output
>i guess it always need machine/server to send email
>could be exportwithformatting a table
>then open an email through msaccessWebBrowser so as to attached file then send to many but not auto run method...
 

Users who are viewing this thread

Top Bottom