I have tried the code below for sending fax:
uses
ComObj, ActiveX, FAXCOMEXLib_TLB;
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
JobIDs: OleVariant;
FaxServer: IFaxServer2;
FaxDocument: IFaxDocument2;
begin
try
FaxServer := CoFaxServer.Create;
FaxServer.Connect('');
FaxDocument := CoFaxDocument.Create;
FaxDocument.Body := 'd:\Document.pdf';
FaxDocument.DocumentName := 'Document name';
FaxDocument.Recipients.Add('+1 (425) 555-4567', 'Bill');
FaxDocument.Sender.Name := 'Bob';
FaxDocument.Sender.BillingCode := '23A54';
FaxDocument.Sender.Department := 'Accts Payable';
FaxDocument.Sender.FaxNumber := '+972 (4) 555-9070';
JobIDs := FaxDocument.ConnectedSubmit(FaxServer);
for I := VarArrayLowBound(JobIDs, 1) to VarArrayHighBound(JobIDs, 1) do
ShowMessage('Job ID: ' + VarArrayGet(JobIDs, [I]));
except
on E: EOleSysError do
ShowMessage(
Format('Sending of the fax failed! %s [%d]', [E.Message, E.ErrorCode])
);
end;
end;
What I was trying to do was get the job status for the fax sent. I have tried to add
var
FaxJobStatus: IFaxJobStatus;
.....
FaxJobStatus := CoFaxJobStatus.Create;
compiled the source code and found no error but after executing the code, it fails at FaxJobStatus := CoFaxJobStatus.Create saying "class not registered".
From the IFaxJobStatus documentation:
So you have to register for the
IFaxServerNotify.OnIncomingJobChanged
orIFaxServerNotify.OnOutgoingJobChanged
events. When the event is received, you get the FaxJobStatus object and can read itsStatus
property.