4

任何人都知道如何使用 Windows 8 Fax true Delphi 发送传真。我的意思是我需要启动带有数字和 pdf 附件的 Windows 传真。任何关于那个的教程?谢谢。

4

1 回答 1

7

例如,您可以使用Fax Service COM Interfaces。对于简单的操作,您可以导入库的类型fxscomex.dll库并使用这样的代码(基于this example):

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;

或者没有类型库也一样:

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  JobIDs: OleVariant;
  FaxServer: OleVariant;
  FaxDocument: OleVariant;
begin
  try
    FaxServer := CreateOleObject('FaxComEx.FaxServer');
    FaxServer.Connect('');
    FaxDocument := CreateOleObject('FaxComEx.FaxDocument');
    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;
于 2013-02-25T00:01:49.687 回答