Solved

Delphi Application fax service / api win 2000

Posted on 2003-10-23
7
1,100 Views
Last Modified: 2012-06-27
I am creating an application that I want to print to the windows fax service, automatically using a fax number extracted from a database table. I want to use the windows 2000 fax service if possible. How can I do this in delphi code? I know I can set the printer index to the fax printer, but this will only bring up the fax wizard. I want to use a fax number from the application.

Regards

Gee!
0
Comment
Question by:Goodangel Matope
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

by:JDuncan
ID: 9609991
I think the fax service is registered as a DDE service and can be accessed using a DDe client components .
0
 
LVL 11

Author Comment

by:Goodangel Matope
ID: 9610859
How do I do this, I have no idea, please assist!
0
 
LVL 3

Expert Comment

by:JDuncan
ID: 9611926
Actually there is an easier way of doing this. If you are using microsoft outlook then you can send a fax simply by sending an email using mapisendmail. You put the fax number in the To: item.

To enable outlook to send faxes all you do is File New Fax and you will be prompted for the outlook cd to add the fax software components.

I can post some mapi mail samples if you want to install the outlook fax software and send using email

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:JDuncan
ID: 9616183
Here is some mapi code to send an email too outlook as a fax , the email part was posted on another question recently . I cannot find it anymore but it is someone elses code I have modified, apologies for this.

Remember you must install the fax software in outlook. You can also send the fax to someone in the address book also.

procedure TSMTPForm.Button1Click(Sender: TObject);
var
  R: cardinal;
  mail: TStringList;
begin
  mail:=tstringlist.create;
  try
    mail.values['to']:='FAX@01224878484';
    mail.values['Subject']:='my fax subject';
    mail.values['body']:='my fax body';
    R:=sendEMail(Application.Handle,mail);
  finally
    mail.free;
  end;
end;

function TSMTPForm.SendEMail(Handle :THandle;Mail :TStrings) :Cardinal;
type
  TAttachAccessArray    = array [0..0] of TMapiFileDesc;
  PAttachAccessArray    = ^TAttachAccessArray;
var
  MapiMessage : TMapiMessage;
  R: array [0..2 ] of TMapiRecipDesc;
  Attachments : PAttachAccessArray;
  AttachCount : Integer;
  i1          : integer;
  FileName    : String;
begin
  fillChar(MapiMessage,SizeOf(MapiMessage),#0);
  Attachments := nil;
  fillChar(R[0],SizeOf(R[0]), #0);
  fillChar(R[1],SizeOf(r[0]), #0);
  if Mail.Values['to'] <> '' then begin
    R[0].ulReserved       := 0;
    R[0].ulRecipClass     := MAPI_TO;
    R[0].lpszName         := StrNew(PChar(Mail.Values['to']));
    R[0].lpszAddress      := StrNew(PChar('SMTP:' +Mail.Values['to']));
    R[0].ulEIDSize        := 0;
    MapiMessage.nRecipCount := 1;
    MapiMessage.lpRecips    := @R;
  end;
  if Mail.Values['Cc'] <> '' then begin
    R[1].ulReserved       := 0;
    R[1].ulRecipClass     := MAPI_CC;
    R[1].lpszName         := StrNew(PChar(Mail.Values['Cc']));
    R[1].lpszAddress      := StrNew(PChar('SMTP:' +Mail.Values['Cc']));
    R[1].ulEIDSize        := 0;
    inc(MapiMessage.nRecipCount);
    MapiMessage.lpRecips    := @R;
  end;
  AttachCount := 0;
  for i1 := 0 to MaxInt do begin
    if Mail.Values['attachment'+inttostr(i1)] = '' then
      break;
    inc(AttachCount);
  end;
  if AttachCount > 0 then begin
    GetMem(Attachments, SizeOf(TMapiFileDesc) * AttachCount);
    for i1 := 0 to AttachCount -1 do begin
      FileName := Mail.Values['attachment'+inttostr(i1)];
      Attachments[i1].ulReserved    := 0;
      Attachments[i1].flFlags       := 0;
      Attachments[i1].nPosition     := ULONG($FFFFFFFF);
      Attachments[i1].lpszPathName  := StrNew(PChar(FileName));
      Attachments[i1].lpszFileName  :=StrNew(PChar(ExtractFileName(FileName)));
      Attachments[i1].lpFileType    := nil;
    end;
    MapiMessage.nFileCount := AttachCount;
    MapiMessage.lpFiles    := @Attachments^;
  end;
  if Mail.Values['subject'] <> '' then
    MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject']));
  if Mail.Values['body'] <> '' then
    MapiMessage.lpszNoteText :=  StrNew(PChar(Mail.Values['body']));
  Result := MapiSendMail(0,Handle ,MapiMessage,MAPI_DIALOG*Ord(Handle<>0) or
    MAPI_LOGON_UI or MAPI_NEW_SESSION, 0);
  // use this if you don't want the dialog box to come up
  //Result := MapiSendMail(0,Handle ,MapiMessage,0, 0);
  for i1 := 0 to AttachCount-1 do begin
    strDispose(Attachments[i1].lpszPathName);
    strDispose(Attachments[i1].lpszFileName);
  end;
  if assigned(MapiMessage.lpszSubject) then
    strDispose(MapiMessage.lpszSubject);
  if assigned(MapiMessage.lpszNoteText) then
    strDispose(MapiMessage.lpszNoteText);
  if assigned(R[0].lpszAddress) then strDispose(R[0].lpszAddress);
  if assigned(R[0].lpszName) then strDispose(R[0].lpszName);
  if assigned(R[1].lpszAddress) then strDispose(R[1].lpszAddress);
  if assigned(R[1].lpszName) then strDispose(R[1].lpszName);
end;


0
 
LVL 4

Accepted Solution

by:
brunomsilva earned 500 total points
ID: 9617987
Hi,

if you don't want to use the API and use the windows 2000 fax service, you have to import the Type Library faxcom 1.0 type library. This option is in your project menu. Install it and then you can use something like this code to send any printable file to the fax. This will open a new window with the application corresponding to the extension and print it. If you want more control, you can explore the other components created after importing the type lib.

var fd: olevariant;
      fs: tfaxserver;
begin
   fs := tfaxserver.Create(application);
   fs.Connect1('');
   fd := fs.CreateDocument('c:\test.txt'); // can be any type of file here as long as you have an application to open it
   fd.FaxNumber := '123';
   fd.Send;
   fs.Disconnect;
end;
0
 
LVL 4

Expert Comment

by:brunomsilva
ID: 9617988
hey, where is stated "if you don't want to use the API", should be "... want to use Outlook"

Cheers,
  Bruno
0
 
LVL 11

Author Comment

by:Goodangel Matope
ID: 9625160
Thanks everybody for the pointers, jduncan for the code. I think Bruno's answer is what I am looking for though, as I did not want to install any other applications such as outlook to send the fax with.

Thanks again for your help

Goodangel
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question