Consultor Eletrônico



Kbase P102107: 4GL/ABL: How to send a fax using the Microsoft fax service extended COM application programming inte
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   24/06/2009
Status: Verified

GOAL:

4GL/ABL: How to send a fax using the Microsoft fax service extended COM application programming interface?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
Windows

FIX:

The following code was translated from a Visual Basic sample code published by Microsoft.
The code is provided for informational purposes. Refer to Microsoft documentation for details on the objects, methods and properties used in this code:

/* Fax Service FAX_PRIORITY_TYPE_ENUM constants */
&GLOBAL-DEFINE fptLOW 0
&GLOBAL-DEFINE fptNORMAL 1
&GLOBAL-DEFINE fptHIGH 2

/* Fax Service FAX_COVERPAGE_TYPE_ENUM constants */
&GLOBAL-DEFINE fcptNONE 0
&GLOBAL-DEFINE fcptLOCAL 1
&GLOBAL-DEFINE fcptSERVER 2

/* Fax Service FAX_RECEIPT_TYPE_ENUM constants */
&GLOBAL-DEFINE frtNONE 0
&GLOBAL-DEFINE frtMAIL 1
&GLOBAL-DEFINE frtMSGBOX 4

/* Fax Service FAX_SCHEDULE_TYPE_ENUM constants */
&GLOBAL-DEFINE fstNOW 0
&GLOBAL-DEFINE fstSPECIFIC_TIME 1
&GLOBAL-DEFINE fstDISCOUNT_PERIOD 2

DEFINE VARIABLE objFaxDocument AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE objFaxServer AS COM-HANDLE NO-UNDO.

/* Create the Application & fax server objects */
CREATE "FAXCOMEX.FaxServer" objFaxServer.
CREATE "FAXCOMEX.FaxDocument" objFaxDocument.

/* Connect to the fax server */
objFaxServer:Connect("").

/* Set the fax body */
objFaxDocument:Body = "C:\WRK91D\Body.doc".

/* Name the document */
objFaxDocument:DocumentName = "My First Fax".

/* Set the fax priority */
objFaxDocument:Priority = {&fptNORMAL}.

/* Add the recipient with the fax number 12225550100 */
objFaxDocument:Recipients:Add("12225550100", "Recipient Name").

/* Choose to attach the fax to the fax receipt */
objFaxDocument:AttachFaxToReceipt = True.

/* Set the cover page type and the path to the cover page */
/* By default, fcptLOCAL will check My Documents\Fax\Personal Coverpages for a .COV file matching the CoverPage property i.e. generic.cov */
/* fcptSERVER will check %WINDIR%\Fax\Personal Coverpages */
objFaxDocument:CoverPageType = {&fcptLOCAL}.
objFaxDocument:CoverPage = "generic".

/* Provide the cover page note */
objFaxDocument:Note = "Here is the info you requested".

/* Specify that the fax is to be sent at a particular time */
objFaxDocument:ScheduleType = {&fstSPECIFIC_TIME}.

/* Set the time to send the fax - format used is YYYY-MM-DD HH-MM-SS*/
objFaxDocument:ScheduleTime = "2009-06-24 12:00:00".

/* Set the fax subject */
objFaxDocument:Subject = "Today's fax".

/* Set the sender properties */
objFaxDocument:Sender:Title = "Mr.".
objFaxDocument:Sender:Name = "Youssif Shanshiry".
objFaxDocument:Sender:City = "Bedford".
objFaxDocument:Sender:State = "Massachusetts".
objFaxDocument:Sender:Company = "Progress".
objFaxDocument:Sender:Country = "USA".
objFaxDocument:Sender:Email = "yshanshi@progress.com".
objFaxDocument:Sender:FaxNumber = "17812804543".
objFaxDocument:Sender:HomePhone = "12165555555".
objFaxDocument:Sender:OfficeLocation = "Downtown".
objFaxDocument:Sender:OfficePhone = "17812803028".
objFaxDocument:Sender:StreetAddress = "14 Oak Park".
objFaxDocument:Sender:TSID = "Office fax machine".
objFaxDocument:Sender:ZipCode = "01730".
objFaxDocument:Sender:BillingCode = "23A54".
objFaxDocument:Sender:Department = "Accts Payable".

/* Save sender information as default */
objFaxDocument:Sender:SaveDefaultSender().

/* Submit the document to the connected fax server */
objFaxDocument:ConnectedSubmit(objFaxServer) NO-ERROR.

/* Disconnect from the fax server */
objFaxServer:Disconnect.