שאלה Send FAX from C#.net application.

  • Monday, October 18, 2010 12:56 PM
     
     

    I am developing a Windows(Desktop) app. in C#.Net 2005

    In this I have to send a fax.

    So I want to know the system configuration (i.e. required OS, telephone line , modem , etc. ) that is required.
    I also want the code.

    Currently we are using Windows XP professional OS for software development and client has Windows 2003 server.

    Also, I don't want to use any third party software or dll.

All Replies

  • Monday, October 18, 2010 4:31 PM
     
      Has Code

    If you have  FAX Services installed from standard Windows components. Here is the code.

    First add reference to faxcom type library 1.0 from com tab of add reference window.

    Here is the method.

    public void SendFax(string parFileName, string parFaxNumber, string parSenderName, string parDisplayName, string parRecipientName)
        {
          FaxServerClass insFaxServerClass = new FaxServerClass();
     
          FaxDoc insFaxDocClass = null;
          try
          {
            insFaxServerClass.Connect(Environment.MachineName);
          }
          catch (Exception ex)
          {
            MessageBox.Show("Error occured");
            return;
          }
     
          try
          {
            insFaxDocClass = (FaxDoc)insFaxServerClass.CreateDocument(parFileName);
          }
          catch (Exception ex)
          {
            MessageBox.Show("Error occured");
            return;
          }
          
          insFaxDocClass.FaxNumber = parFaxNumber;
          insFaxDocClass.SenderName = parSenderName;
          insFaxDocClass.DisplayName = parDisplayName;
          insFaxDocClass.RecipientName = parRecipientName;
     
          try
          {
            insFaxDocClass.Send();
          }
          catch (Exception)
          {
     
            MessageBox.Show("Error occured");
            return;
          }
          
          insFaxServerClass.Disconnect();
        }
    

    and here is how you call this method,

      SendFax(@"C:\Users\Tamer\Desktop\a.docx", "23423423", "sample", "sample", "sample");
    
    
    • Marked As Answer by Jing0Moderator Friday, October 22, 2010 12:21 PM
    • Unmarked As Answer by Harsh1 Monday, December 27, 2010 7:44 AM
    •  
  • Friday, December 24, 2010 9:46 AM
     
     

    Hello Tamer,

    I have added above method to my code but no fax is being sent with this code.

    Do we need to do some more settings?

    Also I don't got any error, above code executed completly.

    In Fax Number I  tried following -

    1) Only Fax Number

    2) STD code +  Fax Number

    3) Country Code + STD code +  Fax Number

    But still no fax is sent to that Fax Number.

    Please give me solution for this problem.

    I don't have any MODEM connected on my computer(we use router). Here we have Lease line internet connection.

  • Friday, March 04, 2011 1:11 PM
     
     

    I was able to send fax using above code.

    But I have problem with sending pdf file, whenever I attach some pdf file -

    insFaxDocClass.Send();

    method opens that pdf.

    I don't want to open this pdf or tell me some way to close this pdf.