473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Employing the FAXCOMEXLib object for more than 1 attachments

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
8 6883
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
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
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
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
SURE , I will try my best
Sep 23 '09 #6
I Forgot to tell you it will work only on windows vista.
Sep 23 '09 #7
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
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

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

Similar topics

15
by: Scott Auge | last post by:
I am looking for comments on something that lets me abstract database updates in an object. Lemme explain what I am thinking: Lets say I have an object Person with... SetFirstName()...
4
by: Neil Zanella | last post by:
Hello, I would be very interested in knowing how the following C++ multi-instance singleton (AKA Borg) design pattern based code snippet can be neatly coded in Python. While there may be...
8
by: Lichunlin | last post by:
Dear all, Sorry for cross posting. I have one page, create an object and save it in session scope, and then redirect to another page.In the new page, the object existed in session object, but...
0
by: Sean McKaharay | last post by:
I am using the code below and I am getting this error: "Insufficient state to deserialize the object. More information is needed." Has anyone seen this? It is working with other dll's but not on a...
15
by: Rick | last post by:
Hi, Does deleting an object more than one times incur undefined behavior? I think it doesn't but just making sure... thanks Rick
65
by: Roger Smythe | last post by:
A means for the progressive decomposition a problem space into increasingly simpler component parts such that these component parts represent higher levels of conceptual abstraction, and are...
12
by: Joe Fallon | last post by:
I would like to know the syntax to check that an Object is a String. If it was a number test I might use IsNumeric. But there is no function: IsString (is there?) -- Joe Fallon
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
19
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string?...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.