Full Version: Disable Save Changes Message When Emailing PDF Report as Attachm
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
zusil
Hi
I'm using Stephen Leban's Report to PDF code to prepare and attach a monthly report to an email group. Everything works very nicely. However, once the email is sent, the "Do you want to save changes to ..." message comes up when closing Outlook. Can this message be eliminated? Changes are not required to be saved.

Thanks
HiTechCoach
What VBA code are you using?
zusil
As always, thanks for the interest...

The code is as follows:

Private Sub cmdMailWarrants_Click()
On Error GoTo Err_cmdMailWarrants_Click

'** Dim blRet As Boolean **Original Lebann Code

DoCmd.OpenReport "rptmonthly", acViewPreview
Reports("rptmonthly").Visible = False
Call ConvertReportToPDF("rptmonthly", , "c:\temp\Warrants.pdf", False, False)

DoCmd.Close acReport, "rptmonthly"

'Open Outlook using the Outlook Object Model:

Dim olapp As Object
Dim olns As Object
Dim olfolder As Object
Dim olitem As Object
Dim olattach As Object

Set olapp = CreateObject("Outlook.application")
Set olns = olapp.getnamespace("MAPI")
Set olfolder = olns.getdefaultfolder(6)
Set olitem = olapp.createitem(0)
Set olattach = olitem.attachments

olitem.To = " "
'olitem.cc = "Whomever"
olitem.Subject = "Monthly Warrants"
olitem.body = "See Attachment"

olattach.Add "c:\temp\warrants.pdf", 1

olitem.Display


Set olitem = Nothing
Set olfolder = Nothing
Set olns = Nothing
Set olapp = Nothing


CleanUpAndExit:
Exit Sub

Err_cmdMailWarrants_Click:
Call MsgBox("An error was encountered" & vbCrLf & _
vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number, , "Error")

Resume CleanUpAndExit


End Sub
zusil
Any ideas at all?
HiTechCoach
I do not see anthing int he VBA code that sends the Email. What sends the email?
zusil
The recipients of the report change each month, therefore the email client (Outlook) opens a new outgoing message with the report already created and attached. The user then chooses the recipents from the address book and sends...

The problem is once the Outlook screen is closed, the save message appears and that's what I would like to eliminate...
HiTechCoach
My guess is that this is caused by the user interacting with the email item.

I have always collected all the information for the email within Access and then send it without any user interaction within Outlook..

As a test, I would try asking for the email address in Access. This will allow you to send the email directly without any user interaction. See if this eliminates the "save" message. If it does, then you will know what was causing the issue.
zusil
That sounds like a possibly elegant soloution but I have no idea how to do something like that from within Access. Can you please supply some more direction
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.