Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Salut
Quelles sont les solutions qui existent pour envoyer des fax via une appli PB 9 ?
Quelles sont les contraintes ?
Avez vous les exemples de code ?...
Merci
Hors ligne
http://pbadonf.fr/forum/viewtopic.php?id=1314
il y a un lien vers un sample codexchange dans le post
Hors ligne
Yes mais c'est en pb10 et je suis en pb9 !
je ne peux pas l'ouvrir ...
Hors ligne
$PBExportHeader$u_nvo_fax.sru $PBExportComments$Contains code related to working with faxes forward global type u_nvo_fax from nonvisualobject end type end forward global type u_nvo_fax from nonvisualobject end type global u_nvo_fax u_nvo_fax type variables // Useful constants constant integer ii_VALIDATE_OK = 0 constant integer ii_VALIDATE_NULLFAXDOCUMENT = -1 constant integer ii_VALIDATE_NORECIPIENT = -2 constant integer ii_VALIDATE_NOFAXNUMBER = -3 constant integer ii_VALIDATE_NOTHINGTOSEND = -4 constant integer ii_VALIDATE_BODYFILENOTFOUND = -5 constant boolean ib_SUCCESS = TRUE constant boolean ib_FAILURE = FALSE end variables forward prototypes private function boolean uf_connect_to_fax_server (string as_server_name, ref oleobject aole_fax_server) public function boolean uf_send_fax (oleobject aole_fax_server, oleobject aole_fax_document, string as_fax_server, u_nvo_fax_document auo_fax_document) public function boolean uf_send_fax (string as_fax_server, u_nvo_fax_document auo_fax_document) public function boolean uf_send_fax_simple (string as_recipient_fax_number, string as_file_name) public function boolean uf_is_fax_services_installed () private function integer uf_validate_fax_document (u_nvo_fax_document auo_fax_document) end prototypes private function boolean uf_connect_to_fax_server (string as_server_name, ref oleobject aole_fax_server);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_connect_to_fax_server // // Description: Connects to a fax server using fxscomex.dll // NOTE: Only tested on a Windows XP machine connecting to the local // fax server, I don;t know how well it works on a remote server // // Scope: private // // Arguments: as_fax_server (string Remote server name, use "" for local machine) // aole_fax_server (oleobject Will contain the connected to fax server) // // Returns: boolean (TRUE = Connected OK, FALSE = Connection failed) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 25.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // See here for IFaxServer documentation: // http://msdn2.microsoft.com/en-us/library/ms689110.aspx // Since this is OLE stuff but not an activex control then we can't trap the events thrown by // the objects, therefore I can't find a way of actually finding out the real error messages that // may be produced. However with a try catch I can at least stop the code from aborting try // First connect to the Fax Server service, this is installed via Windows Components in Add/Remove // Programs, and depends upon fxscomex.dll. It is obly available in Windows XP, Windows 2003 Server, // SBS 2000. I hope it will be available in Vista If aole_fax_server.ConnectToNewObject("FaxComEx.FaxServer") <> 0 Then return ib_FAILURE End If // Now actually connect to the server aole_fax_server.Connect(as_server_name) catch (throwable t) return ib_FAILURE end try return ib_SUCCESS end function public function boolean uf_send_fax (oleobject aole_fax_server, oleobject aole_fax_document, string as_fax_server, u_nvo_fax_document auo_fax_document);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_send_fax // // Description: Sends the fax document specified in auo_fax_document via the fax server // specified in as_fax_server // NOTE: In order to ensure proper DESTROYS of the OLE objects they are // passed in by the caller, and destoyed by the caller when no longer required. // There is an overloaded function that does the create and destroy for you. // // Scope: public // // Arguments: aole_fax_server (oleobject A created oleobject, nothing more nothing less) // aole_fax_document (oleobject A created oleobject, nothing more nothing less) // as_fax_server (string The name of the machine that has the fax server, "" for local) // auo_fax_document (u_nvo_fax_document The fax document to be sent) // // Returns: boolean (TRUE = Sent OK, FALSE = Send failed) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 25.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// integer li_ret long ll_index // Need to verify there is the minimum required information here before continuing If this.uf_validate_fax_document(auo_fax_document) <> 0 Then MessageBox("Fax Handler - Information", "The fax document is invalid and could not be sent.", StopSign!) return ib_FAILURE End If // Connect to the fax server If this.uf_connect_to_fax_server(as_fax_server, aole_fax_server) = FALSE Then MessageBox("Fax Handler - Information", "Connection to the fax server failed.", StopSign!) return ib_FAILURE End If // Create a fax document OLE object li_ret = aole_fax_document.ConnectToNewObject("FaxComEx.FaxDocument") If li_ret <> 0 Then MessageBox("Fax Handler - Information", "Unable to create a new FaxComEx.FaxDocument OLE object.", StopSign!) return ib_FAILURE End If // Fill-in the fax document details. aole_fax_document.DocumentName = auo_fax_document.is_document_name aole_fax_document.CoverPageType = auo_fax_document.ii_cover_page_type aole_fax_document.CoverPage = auo_fax_document.is_cover_page aole_fax_document.Subject = auo_fax_document.is_subject aole_fax_document.Note = auo_fax_document.is_note aole_fax_document.Body = auo_fax_document.is_body // Who is sending the fax aole_fax_document.Sender.Title = auo_fax_document.iuo_fax_sender.is_title aole_fax_document.Sender.Name = auo_fax_document.iuo_fax_sender.is_name aole_fax_document.Sender.Department = auo_fax_document.iuo_fax_sender.is_department aole_fax_document.Sender.Company = auo_fax_document.iuo_fax_sender.is_company aole_fax_document.Sender.OfficeLocation = auo_fax_document.iuo_fax_sender.is_office_location aole_fax_document.Sender.StreetAddress = auo_fax_document.iuo_fax_sender.is_street_address aole_fax_document.Sender.City = auo_fax_document.iuo_fax_sender.is_city aole_fax_document.Sender.Country = auo_fax_document.iuo_fax_sender.is_country aole_fax_document.Sender.ZipCode = auo_fax_document.iuo_fax_sender.is_zip_code aole_fax_document.Sender.Email = auo_fax_document.iuo_fax_sender.is_email aole_fax_document.Sender.FaxNumber = auo_fax_document.iuo_fax_sender.is_fax_number aole_fax_document.Sender.OfficePhone = auo_fax_document.iuo_fax_sender.is_office_phone aole_fax_document.Sender.HomePhone = auo_fax_document.iuo_fax_sender.is_home_phone aole_fax_document.Sender.BillingCode = auo_fax_document.iuo_fax_sender.is_billing_code aole_fax_document.Sender.TSID = auo_fax_document.iuo_fax_sender.is_tsid aole_fax_document.ReceiptType = auo_fax_document.ii_receipt_type aole_fax_document.ReceiptAddress = auo_fax_document.is_receipt_address aole_fax_document.AttachFaxToReceipt = auo_fax_document.ib_attach_fax_to_receipt aole_fax_document.GroupBroadcastReceipts = auo_fax_document.ib_group_broadcast_receipts aole_fax_document.Priority = auo_fax_document.ii_priority // Who is the fax going to (could be multiple different numbers) for ll_index = 1 to UpperBound(auo_fax_document.iuo_fax_recipient) aole_fax_document.Recipients.Add(auo_fax_document.iuo_fax_recipient[ll_index].is_fax_number, auo_fax_document.iuo_fax_recipient[ll_index].is_name) next // Send the fax try aole_fax_document.ConnectedSubmit(aole_fax_server) catch (throwable t) MessageBox("Fax Handler - Information", "Unable to submit the fax to the fax server.", StopSign!) aole_fax_server.Disconnect() return ib_FAILURE end try aole_fax_server.Disconnect() return ib_SUCCESS end function public function boolean uf_send_fax (string as_fax_server, u_nvo_fax_document auo_fax_document);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_send_fax // // Description: Sends the fax document specified in auo_fax_document via the fax server // specified in as_fax_server // // Scope: public // // Arguments: as_fax_server (string The name of the machine that has the fax server, "" for local) // auo_fax_document (u_nvo_fax_document The fax document to be sent) // // Returns: boolean (TRUE = Sent OK, FALSE = Send failed) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 25.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// boolean lb_ret oleobject lole_fax_server, lole_fax_document // Create the required OLE objects lole_fax_server = CREATE oleobject lole_fax_document = CREATE oleobject // Call the function lb_ret = this.uf_send_fax(lole_fax_server, lole_fax_document, as_fax_server, auo_fax_document) // Clean up DESTROY lole_fax_document DESTROY lole_fax_server return lb_ret end function public function boolean uf_send_fax_simple (string as_recipient_fax_number, string as_file_name);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_send_fax_simple // // Description: Sends a very simple fax requiring only minimal parameters. // Note: No cover page is included and no sender information is displayed anywhere // on the fax. This may be illegal in some countries. // // Scope: public // // Arguments: as_recipient_fax_number (string The fax number you are sending to) // as_file_name (string The file you wish to fax) // // Returns: boolean (TRUE = Success, FALSE = Failure) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 25.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// boolean lb_ret u_nvo_fax_document luo_fax_document u_nvo_fax_recipient luo_fax_recipient // Set up the fax document object luo_fax_document.is_body = as_file_name luo_fax_recipient.is_fax_number = as_recipient_fax_number luo_fax_document.iuo_fax_recipient[1] = luo_fax_recipient // Create the required OLE objects // Send the fax using the newly created fax document lb_ret = this.uf_send_fax("", luo_fax_document) // Clean up return lb_ret end function public function boolean uf_is_fax_services_installed ();////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_is_fax_services_installed // // Description: Test to see if the windows fax services are installed on this PC // // Scope: public // // Returns: boolean (TRUE = Yes, installed - FALSE = No, not installed) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 26.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OleObject lole_fax_server // Try connecting to the FaxServer lole_fax_server = CREATE OleObject If lole_fax_server.ConnectToNewObject("FaxComEx.FaxServer") <> 0 Then return ib_FAILURE End If return ib_SUCCESS end function private function integer uf_validate_fax_document (u_nvo_fax_document auo_fax_document);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_validate_fax_document // // Description: Ensure the minimum amount of information required to send a fax has been // entered into the fax document object // // Scope: private // // Arguments: auo_fax_document (u_nvo_fax_document The document to be faxed) // // Returns: integer (TRUE = Valid, FALSE = Invalid) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 26.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// long ll_index // Has the fax document been instantiated? If IsValid(auo_fax_document) = FALSE Then return ii_VALIDATE_NULLFAXDOCUMENT End If // Have any recipients been added to the fax document? If UpperBound(auo_fax_document.iuo_fax_recipient) <= 0 Then return ii_VALIDATE_NORECIPIENT End If // Has something been entered into the fax numbers? for ll_index = 1 to UpperBound(auo_fax_document.iuo_fax_recipient) If IsNull(auo_fax_document.iuo_fax_recipient[ll_index].is_fax_number) or Trim(auo_fax_document.iuo_fax_recipient[ll_index].is_fax_number) = "" Then return ii_VALIDATE_NOFAXNUMBER End If next // If there is not coverpage, then there had better be a body file or there's nothing to send If auo_fax_document.ii_cover_page_type = auo_fax_document.ii_COVERPAGETYPE_NONE Then If IsNull(auo_fax_document.is_body) or Trim(auo_fax_document.is_body) = "" Then return ii_VALIDATE_NOTHINGTOSEND End If End If // If there's a body file, does it exist? If not IsNull(auo_fax_document.is_body) and Trim(auo_fax_document.is_body) <> "" Then If FileExists(auo_fax_document.is_body) = FALSE Then return ii_VALIDATE_BODYFILENOTFOUND End If End If return ii_VALIDATE_OK end function on u_nvo_fax.create call super::create TriggerEvent( this, "constructor" ) end on on u_nvo_fax.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;// This object allows the sending of faxes from Windows XP machines provided they have the following: // // 1. An internal/external modem that is installed in Windows with the correct drivers // 2. Fax Services are installed. This is a Windows component installation // // Once fax services are installed then the following must exist on the PC: // // 1. <windir>\System32\fxscomex.dll exists // 2. HKLM\Software\Classes\FaxComEx.FaxServer should exist in the registry // // This object has only been tested on a local fax server, i.e. connecting to the local machine. // In theory it should be able to connect to a remote fax server. Some of the available options // do not work on a local server, unfortunately I do not knwo how to get the OLE error codes // and only receive a general application error when the wrong setting is set so it's very hard // to work out what can and can't be done and why. // // Things I know don't work on a local fax server: // // 1. Receipts don't appear to work // 2. Setting CoverPageType to local doesn't appear to work // 3. Using parenthesis doesn't work in many fields // // Once a fax has been sent Windows will use the in-built Fax Console to manage the queueing. You will // be able to track the progress of the faxes here. It automatically keeps a list of queued faxes, a list of // sent faxes and shows any faxes that have failed. // // Redial attempts and time between redials can be configured from Control Panel | Phone and Modem Options // // Cover pages can be designed using the in-built Cover Page Designer from the Fax Console end event
$PBExportHeader$u_nvo_fax_document.sru forward global type u_nvo_fax_document from nonvisualobject end type end forward global type u_nvo_fax_document from nonvisualobject autoinstantiate end type type variables // As of 2007/01/24 the IFaxDocument definition can be found here: // http://msdn2.microsoft.com/en-us/library/ms685960.aspx // NOTE: If the fax server is running on Windows XP then only SERVER is valid, other settings will // produce an application error constant integer ii_COVERPAGETYPE_NONE = 0 constant integer ii_COVERPAGETYPE_LOCAL = 1 constant integer ii_COVERPAGETYPE_SERVER = 2 // NOTE: If the fax server is running on Windows XP then only NONE is valid, other settings will // produce an application error constant integer ii_RECEIPTTYPE_NONE = 0 constant integer ii_RECEIPTTYPE_EMAIL = 1 constant integer ii_RECEIPTTYPE_MSGBOX = 4 constant integer ii_PRIORITY_LOW = 0 constant integer ii_PRIORITY_NORMAL = 1 constant integer ii_PRIORITY_HIGH = 2 // User friendly document name, this shows in the fax queue allowing the user // to identify which queued fax is which string is_document_name = "" // Subject field on cover page string is_subject = "" // Specifies whether to include a cover page or not, and if one is to be included whether it is // on the client or server relative to the fax service integer ii_cover_page_type = ii_COVERPAGETYPE_NONE // Specifies the file name, or UNC path, of a standard .cov cover page file string is_cover_page = "generic" // This is the note that is displayed on the cover page string is_note = "" // An array of recipients, alllowing a single document to be sent to multiple recipients u_nvo_fax_recipient iuo_fax_recipient[] // Details about the sender of this document u_nvo_fax_sender iuo_fax_sender // The file name of the file we are faxing, it must be a file that can be printed by right-clicking it // and selecting Print from the menu in explorer on the client machine. If print does not exist // in the menu then that file type can not be faxed string is_body = "" // Some fax systems can inform the user when the fax is successfully sent via email or a MsgBox integer ii_receipt_type = ii_RECEIPTTYPE_NONE // If is_receipt_type is email then this is the email address string is_receipt_address = "" // Attach the body of the fax to the receipt email if one is requested boolean ib_attach_fax_to_receipt = FALSE // Specifies whether a single receipt (FALSE) for each fax sent in a group broadcast is sent or // a summary receipt is sent (TRUE) boolean ib_group_broadcast_receipts = FALSE integer ii_priority = ii_PRIORITY_LOW end variables on u_nvo_fax_document.create call super::create TriggerEvent( this, "constructor" ) end on on u_nvo_fax_document.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
$PBExportHeader$u_nvo_fax_recipient.sru forward global type u_nvo_fax_recipient from nonvisualobject end type end forward global type u_nvo_fax_recipient from nonvisualobject autoinstantiate end type type variables // As of 2007/01/24 the IFaxRecipient definition can be found here: // http://msdn2.microsoft.com/en-us/library/ms689573.aspx // Recipient Name string is_name = "" // Recipient Fax Number, include any number to dial outside lines etc. string is_fax_number = "" end variables on u_nvo_fax_recipient.create call super::create TriggerEvent( this, "constructor" ) end on on u_nvo_fax_recipient.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
$PBExportHeader$u_nvo_fax_sender.sru forward global type u_nvo_fax_sender from nonvisualobject end type end forward global type u_nvo_fax_sender from nonvisualobject autoinstantiate end type type variables // Lots of information pointing to the fax sender. // NOTE: In some countries some of these fields may be legally required on a fax string is_TSID = "" string is_title = "" string is_name = "" string is_department = "" string is_company = "" string is_office_location = "" string is_street_address = "" string is_city = "" string is_state = "" string is_country = "" string is_zip_code = "" string is_email = "" string is_fax_number = "" string is_home_phone = "" string is_office_phone = "" string is_billing_code = "" end variables on u_nvo_fax_sender.create call super::create TriggerEvent( this, "constructor" ) end on on u_nvo_fax_sender.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
$PBExportHeader$u_nvo_pdf.sru forward global type u_nvo_pdf from nonvisualobject end type end forward global type u_nvo_pdf from nonvisualobject end type global u_nvo_pdf u_nvo_pdf forward prototypes public function boolean uf_create_pdf (datawindow adw, string as_pdf_file_name, boolean ab_overwrite_existing) public function boolean uf_create_pdf (datastore ads, string as_pdf_file_name, boolean ab_overwrite_existing) end prototypes public function boolean uf_create_pdf (datawindow adw, string as_pdf_file_name, boolean ab_overwrite_existing);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_create_pdf // // Description: Create a PDF file from the passed datawindow. // NOTE: If you have filtered the datawindow only the filter rows appear in the // PDF (which in my opinion is very useful) // // Scope: public // // Arguments: adw (datawindow Should contain the data to be written to a PDF) // as_pdf_file_name (string The pdf file we are writing to) // ab_overwrite_existing (boolean If TRUE we will just overwrite an existing file) // // Returns: boolean (TRUE = Success, FALSE = Failure) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 26.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // NOTE: If changes are made here please check the other uf_create_pdf function in case the changes also need to be made there string ls_current_printer boolean lb_success = TRUE If ab_overwrite_existing = FALSE Then If FileExists(as_pdf_file_name) Then MessageBox("PDF Writer - Information", "File " + as_pdf_file_name + " already exists, unable to create PDF file.", StopSign!) return FALSE End If End If // Get the current printer as we need to set it back again at the end of this function ls_current_printer = adw.Describe ( "Datawindow.Printer" ) // Set the printer to the one installed by Powerbuilder's PDF fucntionality adw.Modify("Datawindow.Printer='Sybase Datawindow PS'" ) // Specify the PDF creation method adw.Modify("Datawindow.Export.PDF.Method=Distill!" ) // Save the passed datawindow as a PDF to the passed file name If adw.saveas(as_pdf_file_name, PDF!, False) <> 1 Then MessageBox("PDF Writer - Information", "Unable to create PDF file " + as_pdf_file_name + ".", StopSign!) lb_success = FALSE End If // Set the printer back to the original one adw.Modify("Datawindow.Printer='" + ls_current_printer + "'" ) return lb_success end function public function boolean uf_create_pdf (datastore ads, string as_pdf_file_name, boolean ab_overwrite_existing);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function: uf_create_pdf // // Description: Create a PDF file from the passed datastore. // NOTE: If you have filtered the datastore only the filter rows appear in the // PDF (which in my opinion is very useful) // // Scope: public // // Arguments: ads (datastore Should contain the data to be written to a PDF) // as_pdf_file_name (string The pdf file we are writing to) // ab_overwrite_existing (boolean If TRUE we will just overwrite an existing file) // // Returns: boolean (TRUE = Success, FALSE = Failure) // // Revision History: // // Date Author Patch Ref Version Description // ------ -------- ------- ---- --------- --------------------------------------- // 26.01.2007 AC T00 TR7888 3.50.00 6.70.00 Created // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // NOTE: If changes are made here please check the other uf_create_pdf function in case the changes also need to be made there string ls_current_printer boolean lb_success = TRUE If ab_overwrite_existing = FALSE Then If FileExists(as_pdf_file_name) Then MessageBox("PDF Writer - Information", "File " + as_pdf_file_name + " already exists, unable to create PDF file.", StopSign!) return FALSE End If End If // Get the current printer as we need to set it back again at the end of this function ls_current_printer = ads.Describe ( "Datawindow.Printer" ) // Set the printer to the one installed by Powerbuilder's PDF fucntionality ads.Modify("Datawindow.Printer='Sybase Datawindow PS'" ) // Specify the PDF creation method ads.Modify("Datawindow.Export.PDF.Method=Distill!" ) // Save the passed datawindow as a PDF to the passed file name If ads.saveas(as_pdf_file_name, PDF!, False) <> 1 Then MessageBox("PDF Writer - Information", "Unable to create PDF file " + as_pdf_file_name + ".", StopSign!) lb_success = FALSE End If // Set the printer back to the original one ads.Modify("Datawindow.Printer='" + ls_current_printer + "'" ) return lb_success end function on u_nvo_pdf.create call super::create TriggerEvent( this, "constructor" ) end on on u_nvo_pdf.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
$PBExportHeader$w_fax_tester.srw forward global type w_fax_tester from window end type type st_1 from statictext within w_fax_tester end type type em_fax_number from editmask within w_fax_tester end type type cb_fax_simple from commandbutton within w_fax_tester end type type cb_print from commandbutton within w_fax_tester end type type cb_filter from commandbutton within w_fax_tester end type type cb_pdf from commandbutton within w_fax_tester end type type st_os from statictext within w_fax_tester end type type dw_1 from datawindow within w_fax_tester end type type cb_fax from commandbutton within w_fax_tester end type end forward global type w_fax_tester from window integer width = 2203 integer height = 1848 boolean titlebar = true string title = "Untitled" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true st_1 st_1 em_fax_number em_fax_number cb_fax_simple cb_fax_simple cb_print cb_print cb_filter cb_filter cb_pdf cb_pdf st_os st_os dw_1 dw_1 cb_fax cb_fax end type global w_fax_tester w_fax_tester type prototypes Function long ShellExecuteA (ulong hWnd, string Operation, string lpFile, string lpParameters, string lpDirectory, long nShowCmd) library "shell32.dll" alias for "ShellExecuteA;Ansi" end prototypes type variables string is_pdf_file_name = "C:\tmp\dwtest.pdf" end variables forward prototypes public function integer wf_execute_file (string as_file) public function boolean wf_is_windows_fax_services_installed () public function boolean wf_is_powerbuilder_pdf_handler_installed () public function boolean wf_is_os_at_least_xp () end prototypes public function integer wf_execute_file (string as_file);// Same a double-clicking the file in Windows Explorer // See the Local External Functions for the Win32 stuff Long ll_rc String ls_null SetNull( ls_null ) ll_rc = ShellExecuteA ( Handle(this), "open", as_file + Char(0), ls_null, ls_null, 1) return 0 end function public function boolean wf_is_windows_fax_services_installed ();// Checks to see if the fax services have been installed boolean lb_ret u_nvo_fax luo_fax luo_fax = CREATE u_nvo_fax lb_ret = luo_fax.uf_is_fax_services_installed() DESTROY luo_fax return lb_ret end function public function boolean wf_is_powerbuilder_pdf_handler_installed ();// Checks to see if Ghostscript PDF handler has been installed string ls_dummy[] // Note: This registry key may change in PB11 If RegistryKeys ( "HKEY_LOCAL_MACHINE\SOFTWARE\GNU Ghostscript" , ls_dummy ) > -1 Then return FALSE End If return TRUE end function public function boolean wf_is_os_at_least_xp ();// Checks to see if the OS on the PC is at least Windows XP environment le_env GetEnvironment( le_env ) If le_env.osmajorrevision >= 5 and le_env.osminorrevision >= 1 Then return TRUE Else return FALSE End If end function on w_fax_tester.create this.st_1=create st_1 this.em_fax_number=create em_fax_number this.cb_fax_simple=create cb_fax_simple this.cb_print=create cb_print this.cb_filter=create cb_filter this.cb_pdf=create cb_pdf this.st_os=create st_os this.dw_1=create dw_1 this.cb_fax=create cb_fax this.Control[]={this.st_1,& this.em_fax_number,& this.cb_fax_simple,& this.cb_print,& this.cb_filter,& this.cb_pdf,& this.st_os,& this.dw_1,& this.cb_fax} end on on w_fax_tester.destroy destroy(this.st_1) destroy(this.em_fax_number) destroy(this.cb_fax_simple) destroy(this.cb_print) destroy(this.cb_filter) destroy(this.cb_pdf) destroy(this.st_os) destroy(this.dw_1) destroy(this.cb_fax) end on event open;environment le_env long ll_loop, ll_row for ll_loop = 1 to 10 ll_row = dw_1.InsertRow(0) dw_1.object.a_number[ll_row] = ll_row * 10000 dw_1.object.a_string[ll_row] = "This is a test string" Next If this.wf_is_os_at_least_xp() Then st_os.Text = "XP" Else st_os.Text = "" cb_fax.enabled = FALSE cb_fax_simple.enabled = FALSE End If end event type st_1 from statictext within w_fax_tester integer x = 635 integer y = 1612 integer width = 370 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Fax Number:" boolean focusrectangle = false end type type em_fax_number from editmask within w_fax_tester integer x = 1015 integer y = 1588 integer width = 686 integer height = 112 integer taborder = 30 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 borderstyle borderstyle = stylelowered! maskdatatype maskdatatype = stringmask! string mask = "xxxxxxxxxxxxxxxxxxxxx" end type type cb_fax_simple from commandbutton within w_fax_tester integer x = 1728 integer y = 1588 integer width = 402 integer height = 112 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Fax Simple" end type event clicked;// An example of a very simple fax, no sender information is displayed on the fax // just the PDF contents u_nvo_pdf luo_pdf u_nvo_fax luo_fax boolean lb_ret luo_pdf = CREATE u_nvo_pdf lb_ret =luo_pdf.uf_create_pdf(dw_1, is_pdf_file_name, TRUE) DESTROY u_nvo_pdf If lb_ret = TRUE Then luo_fax = CREATE u_nvo_fax luo_fax.uf_send_fax_simple(em_fax_number.Text , is_pdf_file_name) DESTROY luo_fax End If end event type cb_print from commandbutton within w_fax_tester integer x = 887 integer y = 1456 integer width = 402 integer height = 112 integer taborder = 40 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Print" end type event clicked;// I use this to test printing to a PDF file (or a printer of course) dw_1.Print(TRUE, TRUE) end event type cb_filter from commandbutton within w_fax_tester integer x = 466 integer y = 1456 integer width = 402 integer height = 112 integer taborder = 30 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Filter" end type event clicked;// This is to test the PDF file is only created based on the contents of the Primary Buffer dw_1.SetFilter("a_number > 60000") dw_1.Filter() end event type cb_pdf from commandbutton within w_fax_tester integer x = 1307 integer y = 1456 integer width = 402 integer height = 112 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "PDF" end type event clicked;// Create a PDF file from the datawindow and open it in the default PDF reader u_nvo_pdf luo_pdf boolean lb_ret luo_pdf = CREATE u_nvo_pdf lb_ret = luo_pdf.uf_create_pdf(dw_1, is_pdf_file_name, TRUE) DESTROY u_nvo_pdf If lb_ret = TRUE Then parent.wf_execute_file(is_pdf_file_name) End If end event type st_os from statictext within w_fax_tester integer x = 27 integer y = 1456 integer width = 279 integer height = 132 integer textsize = -22 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "?" alignment alignment = center! boolean focusrectangle = false end type type dw_1 from datawindow within w_fax_tester integer x = 14 integer width = 2107 integer height = 1424 integer taborder = 10 string title = "none" string dataobject = "d_test" boolean livescroll = true borderstyle borderstyle = stylelowered! end type type cb_fax from commandbutton within w_fax_tester integer x = 1728 integer y = 1456 integer width = 402 integer height = 112 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Fax" end type event clicked;// An example fax send u_nvo_fax luo_fax u_nvo_fax_document luo_fax_document u_nvo_fax_sender luo_fax_sender u_nvo_fax_recipient luo_fax_recipient u_nvo_pdf luo_pdf boolean lb_ret // Create the PDF nvo and create a fax from the datawindow luo_pdf = CREATE u_nvo_pdf lb_ret = luo_pdf.uf_create_pdf(dw_1, is_pdf_file_name, TRUE) DESTROY u_nvo_pdf // If the PDF create failed then no need to continue If lb_ret = FALSE Then return End IF // Create the FAX nvo luo_fax = CREATE u_nvo_fax // Setup a test fax document with a coverpage luo_fax_document.is_document_name = "Test Fax" luo_fax_document.ii_cover_page_type = luo_fax_document.ii_coverpagetype_server luo_fax_document.is_cover_page = "generic" luo_fax_document.is_subject = String(DateTime(Today(), Now()), "yyyy-mmm-dd hh:mm:ss") + " - Test fax for Aron Cox" luo_fax_document.is_note = "Please forward this fax to Aron Cox" luo_fax_document.is_body = is_pdf_file_name luo_fax_sender.is_title = "Mr." luo_fax_sender.is_name = "John Smith" luo_fax_sender.is_department = "Development" luo_fax_sender.is_company = "My Company" luo_fax_sender.is_office_location = "My Office" luo_fax_sender.is_street_address = "123, Any Street" luo_fax_sender.is_city = "My City" luo_fax_sender.is_country = "My Country" luo_fax_sender.is_zip_code = "My Postcode" luo_fax_sender.is_email = "me@myaddress.com" luo_fax_sender.is_fax_number = "1111111111" luo_fax_sender.is_office_phone = "2222222222" luo_fax_sender.is_home_phone = "3333333333" luo_fax_sender.is_billing_code = "BILL001" luo_fax_sender.is_tsid = "MyFaxMachine" luo_fax_document.iuo_fax_sender = luo_fax_sender luo_fax_recipient.is_name = "Jane Doe" luo_fax_recipient.is_fax_number = em_fax_number.Text luo_fax_document.iuo_fax_recipient[1] = luo_fax_recipient // Send the fax If luo_fax.uf_send_fax("", luo_fax_document) = FALSE Then MessageBox("Information", "Fax was not submitted.") End If DESTROY luo_fax DESTROY luo_pdf end event
$PBExportHeader$d_test.srd release 10; datawindow(units=0 timer_interval=0 color=16777215 processing=0 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no ) header(height=96 color="536870912" ) summary(height=0 color="536870912" ) footer(height=0 color="536870912" ) detail(height=108 color="536870912" ) table(column=(type=number updatewhereclause=yes name=a_number dbname="a_number" ) column=(type=char(80) updatewhereclause=yes name=a_string dbname="a_string" ) ) text(band=header alignment="2" text="A Number" border="4" color="0" x="18" y="16" height="64" width="265" html.valueishtml="0" name=a_number_t visible="1" font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" ) text(band=header alignment="2" text="A String" border="4" color="0" x="302" y="16" height="64" width="2194" html.valueishtml="0" name=a_string_t visible="1" font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" ) column(band=detail id=1 alignment="1" tabsequence=10 border="0" color="0" x="18" y="16" height="76" width="219" format="[general]" html.valueishtml="0" name=a_number visible="1" edit.limit=0 edit.case=any edit.autoselect=yes edit.autohscroll=yes font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" ) column(band=detail id=2 alignment="0" tabsequence=20 border="0" color="0" x="302" y="16" height="76" width="2194" format="[general]" html.valueishtml="0" name=a_string visible="1" edit.limit=0 edit.case=any edit.autoselect=yes edit.autohscroll=yes font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" ) htmltable(border="1" ) htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" ) xhtmlgen() cssgen(sessionspecific="0" ) xmlgen(inline="0" ) xsltgen() jsgen() export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 ) import.xml() export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" ) export.xhtml()
Hors ligne
Bon ce n'est pas tout à fait la réponse à ta question, mais est-ce que ton appli tourne dans un environnement où il y a un serveur exchange ? Car dans ce cas le plus simple est de configurer exchange comme serveur de fax. Ensuite il suffit d'envoyer un mail au serveur avec le numéro de fax en destinataire... J'imagine que d'autres serveurs de messagerie savent le faire également.
L'énorme avantage de cette solution est de centraliser les envois (un seul modem sur le serveur) et de conserver une trace des envois sur le serveur.
Hors ligne
je vois cela et je vous reviens
Merci
Hors ligne
Suivant les besoins bien sur, il existe aussi des solutions toute faites sur internet qui ne coute pas trop cher.
Ces solutions permettent d'envoyer un fax à partir des pièce jointes d'un email.
Il suffit d'envoyer un email avec comme adresse le numéro de fax suivi de l'adresse du serveur.
Le gros avantage de ce genre de solution est que l'on a pas besoin de disposer d'un modem (pas toujours facile lorsqu'on a des config différentes chez chacun des clients). Bien sur ce genre de solution est recommandée à des personnes qui envoient des fax à l'occasion...
Pour une utilisation plus intensive, la procédure décrite précédemment s'impose...
Exemple: www.popfax.com
Bien à vous
Vincent
Hors ligne