Art  Delphi  Automation  History  Home  Politics  Email me Default Colours  Printable Colours

Automating WinFax

I know nothing about WinFax. However, Neil Frewer has kindly provided some sample code, using variants. Thanks, Neil!

// OLE EXAMPLE CODE FOR WINFAX
// -----------------------------------------

  Result := 0;
  try
    oWinFax := CreateOleObject('WinFax.SDKSend');
  except
    ShowMessage('Could not create a WinFax.SDKSend API object');
    Result := 1;
    bFail := TRUE;
    Exit;
  end;

  oWinFax.LeaveRunning;
  if oWinFax.AddAttachmentFile('') = 1 then 
    ShowMessage('Could not add file');
  if oWinFax.SetPrintFromApp(1) = 1 then 
    ShowMessage('Failed Set print');
  oWinFax.SetTo(Details^.FaxRecipientName);

  {Set the fax details in winfax}
  if oWinFax.SetNumber(Details^.FaxNumber) = 1 then
    ShowMessage('Could not set number');
  if oWinFax.SetAreaCode('') = 1 then 
    ShowMessage('Could set area code');

  if oWinFax.AddRecipient = 1 then 
    ShowMessage('Could not add fax recipient');
  if oWinFax.SetPreviewFax(0) = 1 then 
    ShowMessage('Could not set preview');
  if oWinFax.SetUseCover(0) = 1 then 
    ShowMessage('Could not set use cover');
  if oWinFax.SetResolution(0) = 1 then 
    ShowMessage('Could not set resolution');
  oWinFax.Send(0);

  { Wait for the fax program to get ready }
  while oWinFax.IsReadyToPrint = 0 do;

  Sleep(100); {Need this to allow winfax to run. Without this 
	there will be times when winfax will ask for the fax 
	number to call}

  {Wait for an ID from win fax}
  if not bFail then oWinFax.Done;