More on Controlling Windows Fax Services Using VB.Net - Submitting a Job to the Server (Page 3 of 4 )
Ok, now that we know how to get information from the server, it's time to try to send a fax. We are going to send a signal page job from our system, and use one of the built-in cover pages.
You can add your own cover pages easily enough. Just open the Fax services manager on the server, and then right click on Cover page, new, cover page. This will launch the fax page editor and let you design your own cover page. You can add your company's logo and other details, and also drop in components that will be replaced with the recipient's name, number, and so forth when the fax is sent.
Anyway, create another button on your form in Visual Studio, and add this code to it. I will explain it line by line in the next section.
Dim objFaxServer As New FAXCOMEXLib.FaxServer 'connection to the server
Dim objFaxDocument As New FAXCOMEXLib.FaxDocument 'fax document to send
Dim strFaxPDFtoSend As String
'local document to send
strFaxPDFtoSend = "c:TestFax.pdf"
Try
'now we have all the info, we can try and send the job out
'Connect to the fax server
objFaxServer.Connect("fax-svr1")
'Set the fax body
objFaxDocument.Body = strFaxPDFtoSend
'Name the document
objFaxDocument.DocumentName = "Fax from Test Application"
'Set the fax priority
objFaxDocument.Priority = FAXCOMEXLib.FAX_PRIORITY_TYPE_ENUM.fptNORMAL
'Add the recipient with the fax no
objFaxDocument.Recipients.Add("01772 123456", "Luke Niland")
'Set the cover page type and the path to the cover page
objFaxDocument.CoverPageType=
FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptSERVER
objFaxDocument.CoverPage = "generic.cov"
'Provide the address for the fax receipt
objFaxDocument.ReceiptAddress = "luke@beakersoft.wanadoo.co.uk"
'Dont attach the original fax to the email receipt
objFaxDocument.AttachFaxToReceipt = False
'Set the receipt type to email
objFaxDocument.ReceiptType = FAXCOMEXLib.FAX_RECEIPT_TYPE_ENUM.frtMAIL
'Subject into the cover
objFaxDocument.Subject = "Test Fax"
'Set the sender properties.
objFaxDocument.Sender.Name = "Luke Niland"
'Submit the document to the connected fax server
objFaxDocument.ConnectedSubmit(objFaxServer)
Catch ex As Exception
Msgbox("Failed Sending Job" & ex.Message & " " & ex.GetBaseException.ToString)
End Try
Next: Explaining the Code >>
More Visual Basic.NET Articles
More By Luke Niland