Problem using the Win2PDF Mail Helper to batch email PDF files
Posted by Craig Lebakken on 24 October 2007 07:38 PM
When sending PDF files in a batch process using the Win2PDF Mail Helper, some PDF files are attached to the wrong email.
The problem occurs because the Win2PDF Mail Helper sends email asynchronously. When the next print job in a batch is started, it may overwrite the PDF file before the Mail Helper sends the previous PDF file.
You can avoid the problem by adding a polling loop to wait for the Win2PDF Mail Helper to send the PDF before creating the next PDF file. The following VB code will wait for the Mail Helper to finish:
'wait until the Win2PDF Mail Helper has sent the file
result = GetSetting("Dane Prairie Systems", "Win2PDF", "MailHelperResult")
Loop Until result <> ""
You should also add the following line before the call to "DoCmd.OpenReport":
DeleteSetting "Dane Prairie Systems", "Win2PDF", "MailHelperResult"
This code polls for the Mail Helper status code, which is 0 if the email was sent successfully.