More on Controlling Windows Fax Services Using VB.Net - Explaining the Code (Page 4 of 4 )
Okay, the first three lines are our object and the variables we will need. The only object here that we haven't seen before is the FAXCOMEXLib.FaxDocument. This is the object that is used to create the job and send. The other two lines are the connection to the server as we have seen before, and a variable that will hold the document we are going to fax.
Now we are going to set all the properties of the job, and then send it. All this code is in a TRY/CATCH so we can gracefully handle any errors. First of all we connect to the fax server as we have done before. Then, we set the body of our objFaxDocument object to be the document we want to fax.
You can fax any kind of document you like, as long as the PC running your application has the ability to open the document. In this case we are sending a pdf file, so your PC must have Adobe Reader or something similar installed.
Now we will set the other properties of the document. There are more available than what we have used here; these are just a guide. First of all set the DocumentName to be whatever you want to call it -- here we just name it "Test Fax" -- then we set the priority of the job. A higher priority job will get sent before a normal or low one.
Now, we will tell the job where it is going, and who it is going to by adding a recipient to the job. You can add multiple recipients to each job; just use an Add for each one.
After that we set the cover page options. If you don't want a cover page, you can use FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptNONE. This will just send the document. Here we are telling the job to use a cover page on the server, and then giving it the name of the cover page. You can also use a local cover page if you have one.
Next we set the receipt options. We give it an email address to send the receipt to, tell it not to attach the fax document to the receipt, and set the receipt type to be an email.
We then set the subject of the job, and the sender name. We now have enough details to send the fax, so we use the ConnectedSubmit method of the document and give it to the fax server.
If everything has worked okay, look at your fax server's outbox, and your job should be in there!
| 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. |