422,024 Members | 1,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,024 IT Pros & Developers. It's quick & easy.

Employing the FAXCOMEXLib object for more than 1 attachments

P: 3
Hi All,

In my application, I am currently employing FAXCOMEXLib to send out faxes. It works great, but one issue still remains. How can I send out multiple attachments in one Fax transmission using FAXCOMEXLib? As shown in the code snippet below, I only have the code which can only send out one attachment at a time. In return, Windows Fax Server takes my attachment and adds the local cover-page to it.

As I have read on the internet, I know this can be done, but no one has posted any sample codes of how actually it is implemented.

I hope someone out there can reply back with a sample code for this.

Expand|Select|Wrap|Line Numbers
  1.  public int FaxDocument(String TheFile, string faxnumber)
  2.         {
  3.             int JobID = 0;
  4.             FAXCOMEXLib.FaxServer faxsrv = new FAXCOMEXLib.FaxServerClass();
  5.  
  6.             try
  7.             {
  8.                 faxsrv.Connect(Environment.MachineName);
  9.                 var faxdoc = new FAXCOMEXLib.FaxDocumentClass();
  10.  
  11.                 //*** How can I add 2 or more attachments to my fax Body with the use of one coverpage?
  12.                 faxdoc.Body = @"C:\Temp\test.doc";
  13.                 //************************************************************************
  14.  
  15.                 faxdoc.Priority = FAX_PRIORITY_TYPE_ENUM.fptNORMAL;
  16.  
  17.                 faxdoc.CoverPageType = FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptLOCAL;
  18.                 faxdoc.CoverPage = "TestCoverPage";
  19.                 faxdoc.ScheduleType = FAXCOMEXLib.FAX_SCHEDULE_TYPE_ENUM.fstNOW;
  20.                 faxdoc.DocumentName = "Fax Transmission";
  21.                 faxdoc.Recipients.Add(faxnumber, "John Doe");                
  22.                 faxdoc.AttachFaxToReceipt = false;
  23.                 faxdoc.Note = "Here is the info you requested";
  24.                 faxdoc.Subject = "Today's fax";
  25.  
  26.                 faxdoc.ConnectedSubmit(faxsrv);
  27.             }
  28.             catch(Exception ex)
  29.             {
  30.                 MessageBox.Show(ex.Message);
  31.             }
  32.             finally
  33.             {
  34.                 faxsrv.Disconnect();
  35.             }
  36.  
  37.             return JobID;
  38.         }
Thx
Sep 8 '09 #1
Share this Question
Share on Google+
8 Replies


P: 4
Instead of useing faxdoc.Body use faxdoc.Bodies and for submit use faxserver.connectsubmited2

all the attachements store in a single array and assign the faxdoc.Bodies=array
Sep 23 '09 #2

P: 3
Thanks for getting back to me. By any chance, do you have a code snippet that can help me checking on the status of the fax job to make sure if it was successfully faxed, or failed?
Sep 23 '09 #3

P: 4
Please see the bellow sample rugh code. we can play with it. any issues plz mail me.

Dim WithEvents objFaxServer As New FAXCOMEXLib.FaxServer
Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
Dim JobID As Object
Dim STAttach1(1) As String

objFaxServer.Connect(Environment.MachineName)
objFaxServer.ListenToServerEvents(FAXCOMEXLib.FAX_ SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE)
strfilename = ""
STAttach1(0) = "D:\Robofax.pdf"
STAttach1(1) = "D:\Black-ICE.doc"
objFaxDocument.Bodies = STAttach1
objFaxDocument.DocumentName = "MedFax Testing"
Faxnumber = "26"
objFaxDocument.Recipients.Add(Faxnumber, "test")
objFaxDocument.AttachFaxToReceipt = True
objFaxDocument.Note = "TEST FAX (MEDFAX)"
objFaxDocument.Subject = "Testing FAX(MEDFAX)"
objFaxDocument.CoverPageType = FAX_COVERPAGE_TYPE_ENUM.fcptSERVER
objFaxDocument.CoverPage = "generic"
objFaxDocument.Note = "Here is the info you requested" '===Comments files
Dim strJobIds As Object
strJobIds = Nothing

JobID = objFaxDocument.ConnectedSubmit2(objFaxServer, strJobIds)

strJID = JobID(0)
strJobID = "The Job ID is :" & JobID(0)
MsgBox("The Job ID is :" & JobID(0))
'objFaxServer.Disconnect()
Sep 23 '09 #4

P: 3
Once again thank you for this code resource you have posted. I will go ahead and use it right away. Do you also happen to know how can I use the returned JobID from your code and check for the status of my fax (sent, error, processing, etc) in the queue at some other time later? I hope you’ll be able to guide me on this one as well.

Thank you
Sep 23 '09 #5

P: 4
SURE , I will try my best
Sep 23 '09 #6

P: 4
I Forgot to tell you it will work only on windows vista.
Sep 23 '09 #7

P: 1
sonnykei:
You can subscribe to OnOutgoingJobChanged event of the Fax Server Object.
Here's a snippet of my code (written in VB.NET)
I call my window app from a console app (automation):

Expand|Select|Wrap|Line Numbers
  1. -----------------------
  2.  Private Sub g_objFaxServer_OnOutgoingJobChanged1(ByVal pFaxServer As FAXCOMEXLib.FaxServer, ByVal bstrJobId As String, ByVal pJobStatus As FAXCOMEXLib.FaxJobStatus) Handles g_objFaxServer.OnOutgoingJobChanged
  3.     Try
  4.  
  5.       Dim objFaxOutgoingQueue As FAXCOMEXLib.FaxOutgoingQueue
  6.       Dim objFaxOutgoingJob As FAXCOMEXLib.FaxOutgoingJob = Nothing
  7.       Dim sExtendedStatus As String = String.Empty
  8.  
  9.       objFaxOutgoingQueue = pFaxServer.Folders.OutgoingQueue
  10.       objFaxOutgoingJob = objFaxOutgoingQueue.GetJobs.Item(0)
  11.  
  12.       Select Case pJobStatus.Status
  13.         Case FAXCOMEXLib.FAX_JOB_STATUS_ENUM.fjsCOMPLETED
  14.           Me.ListBox1.Items.Add("Fax has completed without errors")
  15.           bOKToExit = True
  16.         Case FAXCOMEXLib.FAX_JOB_STATUS_ENUM.fjsNOLINE
  17.           Me.ListBox1.Items.Add("No fax line available")
  18.           'Cancel the job immediately.
  19.           objFaxOutgoingJob.Cancel()
  20.           bOKToExit = True
  21.  
  22.  
  23.  
  24.  
  25.         Case FAXCOMEXLib.FAX_JOB_STATUS_ENUM.fjsINPROGRESS
  26.  
  27.  
  28.           Select Case pJobStatus.ExtendedStatusCode
  29.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesBAD_ADDRESS
  30.               sExtendedStatus = "->Bad address."
  31.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesANSWERED
  32.               sExtendedStatus = "->Answered."
  33.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesBUSY
  34.  
  35.               sExtendedStatus = "->1.)Busy. 2.)Canceling fax. 3.)Resending Fax."
  36.               'Cancel the job immediately and resend.
  37.               objFaxOutgoingJob.Cancel()
  38.  
  39.               Me.nCurrentRetry += 1
  40.               If (Me.nCurrentRetry <= 3) Then
  41.                 bOKToExit = False
  42.                 Fax()
  43.               Else
  44.                 bOKToExit = True
  45.               End If
  46.  
  47.  
  48.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesCALL_COMPLETED
  49.               sExtendedStatus = "-Fax is complete."
  50.               bOKToExit = True
  51.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesCALL_DELAYED
  52.               sExtendedStatus = "-Fax is delayed."
  53.               'Cancel the job immediately.
  54.               objFaxOutgoingJob.Cancel()
  55.               bOKToExit = True
  56.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesDIALING
  57.               sExtendedStatus = "-Dialing " & Me.m_sParam(1).ToString & "."
  58.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesDISCONNECTED
  59.               sExtendedStatus = "-Fax was disconnected."
  60.               'Cancel the job immediately.
  61.               objFaxOutgoingJob.Cancel()
  62.               bOKToExit = True
  63.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesFATAL_ERROR
  64.               sExtendedStatus = "-Fatal Error!"
  65.               'Cancel the job immediately.
  66.               objFaxOutgoingJob.Cancel()
  67.               bOKToExit = True
  68.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesHANDLED
  69.               sExtendedStatus = "-Handled."
  70.               'Cancel the job immediately.
  71.               bOKToExit = True
  72.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesINITIALIZING
  73.               sExtendedStatus = "-Initializing."
  74.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesLINE_UNAVAILABLE
  75.               sExtendedStatus = "-Line unavailable."
  76.               'Cancel the job immediately and resend.
  77.               objFaxOutgoingJob.Cancel()
  78.               bOKToExit = True
  79.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesNO_ANSWER
  80.               sExtendedStatus = "-No answer."
  81.               'Cancel the job immediately and resend.
  82.               objFaxOutgoingJob.Cancel()
  83.               bOKToExit = True
  84.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesNO_DIAL_TONE
  85.               sExtendedStatus = "-No dial-tone."
  86.               'Cancel the job immediately.
  87.               objFaxOutgoingJob.Cancel()
  88.               bOKToExit = True
  89.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesNONE
  90.               sExtendedStatus = "-(Unknown)."
  91.               'Cancel the job immediately.
  92.               objFaxOutgoingJob.Cancel()
  93.               bOKToExit = True
  94.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesNOT_FAX_CALL
  95.               sExtendedStatus = "-Not a fax call."
  96.               'Cancel the job immediately.
  97.               objFaxOutgoingJob.Cancel()
  98.               bOKToExit = True
  99.             Case FAXCOMEXLib.FAX_JOB_EXTENDED_STATUS_ENUM.fjesTRANSMITTING
  100.               sExtendedStatus = "-Sending page " & pJobStatus.CurrentPage.ToString & " of " & pJobStatus.Pages.ToString
  101.           End Select
  102.           Me.ListBox1.Items.Add(sExtendedStatus)
  103.         Case FAXCOMEXLib.FAX_JOB_STATUS_ENUM.fjsFAILED
  104.           Me.ListBox1.Items.Add("Fax job failed!")
  105.           'Cancel the job immediately.
  106.           objFaxOutgoingJob.Cancel()
  107.           bOKToExit = True
  108.         Case FAXCOMEXLib.FAX_JOB_STATUS_ENUM.fjsRETRYING
  109.           Me.ListBox1.Items.Add("Retrying fax.")
  110.           bOKToExit = False
  111.         Case FAXCOMEXLib.FAX_JOB_STATUS_ENUM.fjsRETRIES_EXCEEDED '*This case statement will never fire, as we handle retries elsewhere.
  112.           Me.ListBox1.Items.Add("Retries exceeded")
  113.           'Cancel the job immediately.
  114.           objFaxOutgoingJob.Cancel()
  115.           bOKToExit = True
  116.       End Select
  117.  
  118.     Catch ex As Exception : End Try
  119.  
  120.  
  121.     If (bOKToExit) Then
  122.       'Okay to shutdown the application.
  123.       End
  124.     End If
  125.  
  126.   End Sub
  127. -------------------------
Nov 18 '09 #8

P: 2
Interesting issue and solution. FYI, there’s a page that documents common FAXCOMEXLib problems and solutions on the Interfax site:
http://www.interfax.net/en/dev/faxcomexlib
If you have any more related issues, it includes information collected from major developer Web forums (including links to the discussions).
Feb 27 '11 #9

Post your reply

Sign in to post your reply or Sign up for a free account.