For a company, 7-PDF Printer was configured as a network pdf printer that was used as PDF Invoice printer directly from a ERP SAP system.
After pdf creation the generated pdf-file is delivered to a FAX-Server for sending the PDF via FAX. For this, a user can put the fax-number to an input-field by 7-PDF Printer. After 7-PDF Printer has generated PDF and has the fax-number, it send all via SMTP to the fax-server.
The example code shows that complex process above. All this with some few lines of VBScript Code in conjunction with 7-PDF Printer. Enjoy!
You can do it directly now!
From version 12, which was released at the end of October 2020, you can also address an SMTP server directly without VBScript, or dynamically change the SMTP server using VBScript at runtime. You can find more information here...
- Dim global_success, faxnr, SMTPServer, Recipient, From, Subject, Message
- Sub OnConfigLoaded()
- Rem -- Modify the configuration to extract text from the printer
- Rem -- output.
- faxnr = InputBox("Fax number entry (without special characters and spaces):", "Send invoice")
- Context("Config")("showsettings") = "never"
- Context("Config")("showpdf") = "no"
- Context("Config")("output") = "C:\pdf-processing\print\<date>-<time>.pdf"
- Context("Config")("superimpose") = "C:\pdf-processing\print\background.pdf"
- Context("Config")("author") = "<username>"
- Context("Config")("confirmoverwrite") = "no"
- Context("Config")("mergefile") = "C:\pdf-processing\print\agb.pdf"
- Context("Config")("mergeposition") = "top"
- End Sub
- Sub OnSuccess()
- global_success = true
- End Sub
- Sub OnAfterPrint()
- If global_success Then
- Rem -- Absender <username>@mailserver.de
- Rem -- Empfänger firstname.lastname@example.org
- SMTPServer = "smtp.mailserver.local"
- Recipient = faxnr & "@fax.local"
- From = Context("DocumentAuthor") & "@mailserver.de"
- Subject = "Your SAP Invoice"
- Message = "Enclosed you will receive your SAP invoice for the
- Technician's order of the technician " & Context("DocumentAuthor")
- & vbcrlf & "Thank you for your order!"
- set msg = CreateObject("CDO.Message")
- msg.From = From
- msg.To = Recipient
- msg.Subject = Subject
- msg.TextBody = Message
- ' To add an attachment uncomment this line
- msg.AddAttachment Context("OutputFileName")
- msg.Configuration.Fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
- msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- MsgBox "The bill has been sent."
- ' Del PDF
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- MsgBox "An error occurred while sending the invoice. Please try again!"
- End If
- End Sub
Download Example File
You can download and run the example yourself. The files needed are available here. The VBS file must be placed in the macros sub folder of the PDF writer installation. You can use the MacroDir setting to change the location of the VBS files if needed.
|Example file||1.1 KB|