PDFCreator COM Interface not working

I am trying to write a script with PDF Creator to send a report to PDFCreator, have it convert it and then email it. I am using Visual FoxPro 9 (VFP) but it is very simple code. Here it is:

*-- This is a test
PUBLIC goQ as PDFCreator.JobQueue
LOCAL loJ as PDFCreator.PrintJob, lcFileName

*-- Instantiate and initalize PDFCreator

goQ = CREATEOBJECT("PDFCreator.JobQueue")
goQ.Initialize()

*-- Create a random filename in the current directory
*-- I will use that in the Job settings
lcFileName = CURDIR()+SYS(2015)+".pdf"

*-- send the report to PDFCreator

SET PRINTER TO PDFCreator
REPORT FORM zipcodes ENVIRONMENT TO PRINTER NOCONSOLE

*-- PDFCreator pops up a SaveAs dialog here. I hit enter as fast as I can

IF !goQ.WaitForJob(20)
	MESSAGEBOX("Error getting print job.",16)
ELSE
	loJ = goQ.NextJob()
	loJ.SetProfileByGuidOrName("VisionPoint")
	loJ.SetProfileSetting("EmailClientSettings.Recipients", "njChazzan@gmail.com")
	loJ.SetProfileSetting("EmailClientSettings.RecipientsBcc", "bazianm@gmail.com")
	loJ.SetProfileSetting("EmailClientSettings.Subject", "Your invoice from Emerson Recycling")
	loJ.ConvertTo(lcFileName)
ENDIF

goQ.ReleaseCom()
	

Like I said, I think the quote is pretty straightforward. What is happening is this: When I send the report to the printer, it pops up a saveas screen. I hit SAVE, it completes the conversion, and opens PDF Architect. The job is never found in the queue.

I am using PDFCreator Professional. I have the default profile set to save automatically and I added an SMTP account to the default profile. I am NOT loading a profile so it should use the default, right?

THanks up front for your help.

Hi,

I'm a Visual Foxpro developer so I have really tested your code.

I'm using:
PDFCreator free, version 5.3.1.0
Windows 11 Pro 23H2
Visual Foxpro 9 SP2 with all the well known subsequent patches

In mine test, the SaveAs dialog don't show up, but I have not added an SMTP account to the default profile, so the Thunderbird mail composition windows opens up (sometimes in the background).

Resolved this erroneous behavior, probably you will find that you need to make two corrections.

  1. The line
    lcFileName = CURDIR()+SYS(2015)+".pdf"
    must be
    lcFileName = set("DEFAULT") + CURDIR()+SYS(2015)+".pdf"

  2. Add the line
    loJ.AddAction("EmailClientSettings")
    after the line
    loJ.SetProfileByGuidOrName("VisionPoint")

In my test I'm using the default profile "DefaultGuid" and everything works well.

After more research and testing, now I'm able to send email using smtp, starting from a configuration similar to yours.

1 Add the line
loJ.AddAction("EmailSmtpSettings")
after the line
loJ.SetProfileByGuidOrName("VisionPoint")

2 In the subsequent lines, change EmailClientSettings in EmailSmtpSettings

3 If you want to specify the body of your mail, add a line like this after the line in which you setup the Subject
loJ.SetProfileSetting("EmailSmtpSettings.Content", "Hi," + chr(13) + chr(10) + "your invoice from Emerson Recycling is attached.")

Thanks.

I just cannot seem to get to that point. Even though the default profile has an autosave setting, it is prompting for a file name (I specified a file name in the default profile). I cannot load the profile until after I get a reference to the job but the job completes while WaitForJob is executing and I never get the opportunity to call NextJob().

The Default and the VisionPoint profiles should be set without autosave:
you don't need it because you control it with your code.

The only difference between the Default and the VisionPoint profiles is that the Default profile is set to open the created pdf with the Default Windows viewer, the VisionPoint profile is set to Email (SMTP): your_mail@abc.it

Try the same configuration.