Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Programmatically Controlling Windows Fax S...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Programmatically Controlling Windows Fax Services Using VB.net
By: Luke Niland
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2007-07-16

    Table of Contents:
  • Programmatically Controlling Windows Fax Services Using VB.net
  • Setting Up the Fax Server
  • Starting to Write the Application
  • Connecting to the Fax Server

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Programmatically Controlling Windows Fax Services Using VB.net - Connecting to the Fax Server


    (Page 4 of 4 )

    As a test the first thing we will do is make sure we can connect to the fax server. This is very simple and can be achieved with just a few lines of code. Put a button on your form, and in the click event of the button type the following code. Each part is discussed underneath:

     Dim objFaxServer As New FAXCOMEXLib.FaxServer

     Dim objFaxOutgoingQueue As FAXCOMEXLib.FaxOutgoingQueue

      

           Try

                'Connect to the fax server.

                objFaxServer.Connect("srv-fax1")

     

                'Create the outgoing queue

                  objFaxOutgoingQueue = objFaxServer.Folders.OutgoingQueue

               

                'Ensure that the queue is not blocked or paused

                objFaxOutgoingQueue.Blocked = False

                objFaxOutgoingQueue.Paused = False

     

                'Set the number of retries

                objFaxOutgoingQueue.Retries = 3

                'Set the retry delay no of minutes

                objFaxOutgoingQueue.RetryDelay = 1

     

                'save the prefs

                objFaxOutgoingQueue.Save()

     

                Msgbox("Fax Settings Saved")

     

            Catch ex As Exception

                  Msgbox("Fax Error" & vbnewline & ex.message)

                Exit Function

            End Try

     

    The first two lines of code are variables that hold the connections to the server, and the outgoing queue properties. Both types live in the FAXCOMEXLib, as does everything else we use when talking to and configuring the server.

    We enclose the whole block of code in a Try Catch block, so we can handle any exceptions gracefully. The first line within the Try is connecting to the fax server, using the objFaxServer variable's Connect method. You just need to give it the name or the IP address of the server. Here it is hard coded but in the real world you would probably put the server name in a config file, or look it up directly.

    Once we have a connection, we can start to set the outgoing queue options. The next section of code sets our objFaxOutgoingQueue variable to be the current Outgoing queue of the server (basically, the variable now contains the current settings on the outgoing queue). Then we make sure the outgoing queue is ready to send out jobs by telling it not to be blocked, or paused. Then, we set the number of retries for the job (in this case three) and how long in minutes to wait before each retry (in this case one).

    We then call the Save method of the queue variable to write out new settings down to the server. If you don't call the Save method, none of the setting we have specified will change so it's very important to remember to do this. The rest of the code just pops up a message box, and closes the Try/Catch.

    If all has gone well, at this point when you run the code you should be given a message box telling you the new settings have been saved. However, if an error has occurred somewhere you will get a message saying 'Fax Error' along with a description of the error.

    As this code is not doing much apart from really testing connectivity between you and the service, the error is probably going to be something involving the name of the server being wrong (in the objFaxServer.Connect("srv-fax1") line), or possibly a security issue. The error message normally gives you a good indication of what has happened.

    If all has gone well, you are now ready to start sending jobs to the server and getting its current load and jobs. This is covered in part two of the article, so stay tuned!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hi,Hope you find this article interesting, any comments or suggestions leave...
       · We have just started testing the Windows fax servie on Windows 2003 server. The...
     

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek