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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email problem

Status
Not open for further replies.

kwor

MIS
Dec 10, 2008
35
AU
I am running Windows 7 (64bit) and Office 2010
I have a database that creates a pdf document on disk and a button that calls my email program, attaches the docuemnt and leaves the new email open for edit. The code is:

stEmail = Me.Parent!Email
stFileName = "D:\documents\abc_" & Me.varNumber & ".pdf"
DoCmd.OutputTo acReport, stDocName, acFormatPDF, stFileName
DoCmd.SendObject acSendReport, stDocName, acFormatPDF, stEmail

This used to work. Now it creates the pdf but displays an Access message that "it can't send this email message"

I can replace the "SendObject" line with:
Application.FollowHyperlink "mailto:" & stEmail

This calls the email program correctly.

By default I use Thunderbird but I changed to Outlook and the same problem occurs, so, it appears to be an Access problem.
It is the "SendObject" line that casues the problem.

Has an Access update broken the system?
Please Help!
 
Surely you get an error message that says more than:
it can't send this email message

What's the full message?

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
That is the full message. to be specific:
"<Database Name> can't send this email message"

Not very helpfull.
I have played around with the code and debugging trying to trap errors. I suspect that it may be runtime Error 2293

I have substituted CDO code as a workaround. This works but I have to supply the smtp information. This database is used at various sites with various smtp information, so in the long run this is painful.

The specific code that fails (without the pfd file generation) is the SendObject line:

Private Sub pdf_Click()
On Error GoTo Err_pdf_Click
Dim stDocName As String
Dim stEmail As String
stDocName = "rptABC"
stEmail = Me.Parent!Email
DoCmd.SendObject acSendReport, stDocName, acFormatPDF, stEmail
Exit_pdf_Click:
Exit Sub
Err_pdf_Click:
MsgBox Err.Description
Resume Exit_pdf_Click
End Sub
 
This thread (a different forum) looks like it may cover your exact problem. I didn't read it really closely, but I'd suggest taking a look.. specifically at how they are using DoCmd.Send...

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Sorry, you didn't list the thread....
 
OH man... Fooey... and I'm just now looking back at this... I'll see if I can find it again, sorry. [blush]

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
You dont need both DoCmd.SendObject and DoCmd.OutputTo.
Just use DoCmd.SendObject , It will convert the report to .pdf without needing to save to disk.

I have had success with
DoCmd.SendObject acSendReport, "Invoice", acFormatPDF, varCustomerEmail, , , "Subject", "Message Text", False

Invoice being the name of the report
varCustomerEmail being the customers email address
Subject is the subject line of the email
Message Text is the body of the email.
The trailing false is to automatically send, true is open in outlook for editing before sending.
This only works for outlook, Advanced MAPI will work for other email clients.
If you are interested in changing the name of the .pdf or disabling the Outlook security prompt, these can also be done using this simple MAPI.
 
In your example, your main problem is that SendObject is expecting stDocName to be the name of the report you want to convert to .pdf and email. Are you trying to pass a file path instead?
 
kjv1611.
Thanks, I have been down that road. Even Microsoft can't get it right between Outlook and Outlook Express. I have tried all that and it doesn't work. I am thinking that perhaps an Access update has broken it but..


thefarg.
The OutpuTo command is used to save a pdf copy to disk and had nothing to do with SendObject. Please refer to my seconf post which shows only the required code.
My original code did work:
DoCmd.SendObject acSendReport, stDocName, acFormatPDF, stEmail

It appears the "True" and "False" are problematic with different versions of Access and Outlook.

I have taken the database and run it under Access 2007 - it works perfectly. But it doesn't work with 2010.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top