PowerBuilder Support

Accelerate development with PowerBuilder, the market’s favorite 4GL RAD tool.

Please can anyone tell me how i can genarate PDF files and attach same to my mail using easymail.

Share

Reply to This

Replies to This Discussion

There are a number of royalty-free, but not cheap, products that can do generate PDFs (using PDF "printers" to print DWs). I use the novaPDF SDK, and it works well.

novaPDF has an option to email a PDF after you create it, but I haven't really tested that. And I don't know what "easymail" is so I can't comment on that.

Reply to This

Please Dan, the novaPDF SDK you talked about how did you achieve that because i tried Amyuni PDF converter from my powerbuilder application but encounetr error at this 'PDFPrinter = Mail.PDFDriverInit("Amyuni PDF converter") '. It is returning 0 for PDFPrinter . What could be the problem.

oleobject Mail
Long rt1
String PDFPrinter

Mail = create oleobject
rt1 = Mail.ConnectToNewObject("cdintfEx.cdintfEx")
PDFPrinter = Mail.PDFDriverInit("Amyuni PDF converter")
Mail.SetResolution (PDFPrinter, 600)
Mail.SetDefaultConfig (PDFPrinter)
Mail.SetDefaultPrinter (PDFPrinter)
Mail.SetDefaultFileName (PDFPrinter, OutputFileDll )

IF rt1 <> 0 THEN
Messagebox("Error", "Unrecoverable Error Occurred Creating Mail Object!")
ELSE
mail.Reset
mail.MailServer = 'mail.dns9.net'
mail.FromAddr = 'odiswansea@yahoo.com'
mail.From = 'swansea'

IF dw_2.GetItemNumber(ll_row,'selected') = 1 THEN
ld_investorid = dw_2.GetItemDecimal(ll_row,'investor_id')
ls_recipient = dw_2.GetItemString(ll_row,'email')
ls_fullname = dw_2.GetItemString(ll_row,'full_name')

ls_msg = "Dear "+ ls_fullname + "~n"
ls_msg = ls_msg + " ~n"
ls_msg = ls_msg + "Please find attached copy of your Client statement." + "~n"
ls_msg = ls_msg + " ~n"

ids_statement.Retrieve(gl_schemeid,ld_investorid,gdt_trans,ld_bid,ld_offer)

ls_desc = 'C:\STATEMENTS\'+String(ld_investorid)
IF FileExists(ls_desc+ '.pdf' ) THEN
FileDelete(ls_desc+ '.pdf')
End If
ll_save = ids_statement.SaveAs(ls_desc + '.pdf', PDF!, FALSE)

Mail.SetFileNameOptions (PDFPrinter, NoPrompt + UseFileName )
Mail.EnablePrinter(pdfPrinter,LicensedTo,ActivationCode)
ids_statement.print() // Print the list
ll_save = ids_statement.SaveAs(ls_desc + '.pdf', PDF!, FALSE)
Mail.SetFileNameOptions (PDFPrinter, 0) // Reset file options
Mail.DriverEnd (PDFPrinter) // Restore the default printer.

END IF
ls_recipient = TRIM(dw_2.GetItemString(ll_row,'email'))
w_mail_progress.st_1.Text = "Verifying address ..." + ls_recipient

IF NOT f_validate_email(ls_recipient) THEN
w_mail_progress.lb_1.AddItem(String(ll_row)+ ": Failed Verification! -> "+ ls_recipient )
ELSE
w_mail_progress.st_1.Text = "Sending Mail to -> " + ls_recipient
mail.AddRecipient(ls_fullname,ls_recipient,1)
mail.Subject = ls_subject
mail.BodyText = ls_msg
IF Mail.SendMail("ls_recipient", "", "", "Test","A PDF has been attached","ls_desc;FirstFile.PDF",1) = 0 THEN
w_mail_progress.lb_1.AddItem(String(ll_row)+ ": Successfully sent! -> "+ ls_recipient )
li_count = li_count + 1
ELSE
w_mail_progress.lb_1.AddItem(String(ll_row)+ ":Error Sending message! -> "+ ls_recipient )
END IF
END IF

mail.disconnectobject()

Reply to This

I did try Amyuni as well. I think I got it to work, but I preferred novaPDF for some reasons. Either it was faster, or the PDFs it created were smaller, or something. (Sorry, can't remember exactly.) Plus, novaPDF was cheaper, I think.

Anyways, what I think I discovered with Amyuni is that their OLE control isn't the sort that you can just create with ConnectToNewObject. Instead, you have to embed it in a window as a dropped-in control. So, I created an invisibile window at program startup, which contained the control, and used it from there. I'm attaching my code for that window. You can retrieve the OLE object from that window with the wf_get_printerobj() method, and then work with it as you do above.

You also need to destroy the window on program exit, I think.
Attachments:

Reply to This

Hello Dan,
Quite grateful, please can you send me the link to downloading the novaPDF you talked about and possible guide on how i can get it working for me.

Reply to This

Swansea, you do have to be willing to do a bit of the work yourself. All you have to do is Google "novaPDF" and it will come up. And their docs are pretty good.

Reply to This

RSS

© 2009   Created by Jason Fenter on Ning.   Create a Ning Network!

Badges  |  Report an Issue  |  Privacy  |  Terms of Service