Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate conversion of datareports to PDF then email 2

Status
Not open for further replies.

mungulya

Programmer
Mar 13, 2008
4
KE
Hi, there,

I have an application done in VB6 and reports designed using datareport!

Now my client wants to email Invoices from the application as PDF files and wants it automated. Already installed is PDF Printer but the downside is it prompts the user for the name of every invoice to be converted to PDF, which is too manual assuming you have got more than 50 invoices you want converted and emailed! How do you automate this in VB6, such that the user just clicks a button and all the conversions are done silently without those prompts!

Please help, will Appreciate any suggestions or a different way of achieving the same.

Thanks

David
 
If I suppose that you are using a function that converts an invoice to pdf format and the problem is that you have so many invoices to give every time its names. I think that you need a loop statement for example,

Rs is you recordset represents invoices
For i=1 to rs.RecordCound 'or to for i=1 to 50
'do here the convertion and email
'you access every record (invoice) via rs
'without have an inputbox requests you everytime a name of invoice
next i

Hope it helps.
 
Have you turned off the "prompt for pdf filename" box
on printing preferences in the Acrobat settings?

"Business conventions are important because they demonstrate how many people a company can operate without."
 
If memory serves, ghostscript has a command line interface.

-Brian
 
Hi, thanks all,

At least to understand where am coming from, the installed Acrobat Pdf Printer is ver 4.0, and as genomon points out, it doesn't provide anywhere to turn on/off any 'prompts for pdf filename', thus am still stuck.

Will try ghostscript option as Brian suggests.

Still open for any suggestions,

Thanks all for your time.


Mungulya

 
Thanks all, now with Pdfcreator, I can automate, except now am getting another snag with OutLook, How can I suppress the message "A program is automatically trying to send email on your behalf"

Any suggestions?
 
An easier way is to download and register the old CDO.dll from Microsoft. The newer one is 1.2.1s - you want 1.2.1.

"Business conventions are important because they demonstrate how many people a company can operate without."
 
Sorry to be so brief before. Here is the fix:
Download and register cdo 1.2.1 to C:\Program Files\Common Files\System\Mapi\1033\cdo.dll.

"Business conventions are important because they demonstrate how many people a company can operate without."
 
To help with the emailing part...

Use CDO to do the sending. Below is a VBScript that shows how to use CDO to send and email without getting the security prompts.

Code:
Dim objMsg
Set objMsg = CreateObject("CDO.Message")
Dim iCounter 

'Importance 
Const cdoLow = 0
Const cdoNormal =  1
Const cdoHigh  =  2

'Delivery Status Notification 
Const cdoDSNDefault = 0 		'No delivery status notifications are issued.
Const cdoDSNNever = 1 			'No delivery status notifications are issued.
Const cdoDSNFailure = 2			'Returns a delivery status notification if delivery fails.
Const cdoDSNSuccess = 4			'Returns a delivery status notification if delivery succeeds.
Const cdoDSNDelay = 8			'Returns a delivery status notification if delivery is delayed.
Const cdoDSNSuccessFailOrDelay = 14	'Returns a delivery status notification if delivery succeeds, fails, or is delayed
 

With objMsg
    .Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
    .Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "xsmtp.company.com" 'SMTP Server
    .Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60
    .Configuration.Fields.Update
    .TextBody = "Test " & iCounter
    .To = "somebody@company.com"
    .From = "John Smith <john.smith@company.com"
    .Subject = "Subject"
    .Fields("urn:schemas:httpmail:importance") = cdoHigh
    .DSNOptions = cdoDSNDefault
    .Fields.Update
    .Send
End With
 
dglienna 15 Mar 08 17:55 said:
You can use this, which is free. You can print from VB

Though free, if you directly link your application to it, such as using a reference to it's dll, then there are certain licensing agreements you may need to apply, such as possibly your programm also needing to fall under the GPL license.
Just thought I'd through that in. Using it just as another printer driver through the common dialog as dglienna is suggesting should be alright, as long as distributed seperately as free.
 
Hi, am so in debted to all of you because of your contributions.

Am glad to report that my problem is solved and I am using the PdfCreator to 'silently' convert the Invoices to PDF, then email them as attachments.

The Outlook pop-pups, have downloaded and Installed Express ClickYes(a simple program that 'auto-clicks' the Outlook security prompt for me. And the client is very happy and touting my resourcefulness and all this goes to you the great minds behind all this.

Thanks all,

Mungulya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top