Sending Mail from Access 2007

J

Jody

I am using the following code to send a report:
Code:
Private Sub RunReport_Click()
On Error GoTo Err_RunReport_Click

Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef
Dim stDocName As String

Set dbCurr = CurrentDb()
Set qdfCurr = dbCurr.QueryDefs("AppendConsumerTable")
With qdfCurr
.Execute dbFailOnError
If .RecordsAffected > 0 Then
DoCmd.SendObject acSendReport, "Replacement_Rpt_Qry2", acFormatSNP,
"[email protected]", , , "Consumer GP Orders Needed", "Please review the
attached document and take the necessary action.", 0
DoCmd.OpenQuery "UpdatePartSentQuery"
DoCmd.OpenQuery "DeleteConsumerTable_qry"
DoCmd.OpenQuery "DeleteInvalidhistoryRecords_qry"
DoCmd.OpenForm "Menu"
DoCmd.CLOSE acForm, "Confirmation"
End If
End With

Exit_RunReport_Click:
Exit Sub

Err_RunReport_Click:
MsgBox Err.Description
Resume Exit_RunReport_Click

End Sub

This is working in the live application, but I am doing some development on
a copy of the database and I get the following message:

"[MyDatabaseName] can't open the mail session."

I have not done any modifications to this particular bit of code, but this
is the only code that calls for this functionality. Any clue what the
resolution to this error is?
 
J

Jody

Actually, this DOES NOT display my database name. This appears to be a
custom message coming from somewhere in the database that I must have put in
at some point. Still, what would make it not be able to open the mail
session?
 
A

Arvin Meyer [MVP]

From the code window, check the references (Tools >>> References) and make
sure that you have a default MAPI mail client configured.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top