Trouble with C# and FAXCOMEXLib: Fax Service Extended COM API (faxcomex.dll)

  • Thread starter Patrick Kenney via AdminLife
  • Start date

P

Patrick Kenney via AdminLife

Trouble with C# and FAXCOMEXLib: Fax Service Extended COM API (faxcomex.dll)

Hello all,

I am having trouble retreiving the Fax Status using C#...

Also I can only seem to set FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM one at a time...

I can see at run-time that I am Registering the FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED Event

or which ever SINGLE FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM enum I use...

And my fax works just fine with this code, but does not appear to be correctly raising the FaxJobStatus events no matter which enum I use...

Am I missing something obvious?
Thanks in advance.

using System;

using System.IO;

using System.ComponentModel;

using System.Collections;

using System.Runtime.InteropServices;

using System.Diagnostics;

using System.Threading;

using FAXCOMEXLib;

namespace csFaxComponent

{

public class csFax

{

protected FAXCOMEXLib.FaxDocument objFaxDocument = new FAXCOMEXLib.FaxDocumentClass();

protected FAXCOMEXLib.FaxServer objFaxServer;

protected object JobID;

public static void Main()

{

try

{

csFax objcsFax = new csFax();

string FileName;

objcsFax.objFaxServer = new FAXCOMEXLib.FaxServer();

objcsFax.objFaxServer.Connect("AFaxServer");

//Register for server Fax Job Status events, this method has a pointer to the

//IFaxServerNotify Interface that implements the FaxJobStatus Class, that enables the

//caller to receive dynamic status messages...

//You do not create the FaxJobStatus class directly it is received as part of a

//notification when you implement "ListenToServerEvents"

//Having trouble with multicasting this enum, Microsoft has a VB 6 example that does not appear to convert well to C#

objcsFax.objFaxServer.ListenToServerEvents(FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED);

// objcsFax.objFaxServer.ListenToServerEvents(FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE);

//E.G.: objFaxServer.ListenToServerEvents fsetFXSSVC_ENDED + fsetOUT_QUEUE (C# version I would think the paren's () would be the only diff, can't make it fly though...)

//Implement fax event status handers...
objcsFax.objFaxServer.OnOutgoingJobAdded +=new IFaxServerNotify_OnOutgoingJobAddedEventHandler(objFaxServer_OnOutgoingJobAdded);

objcsFax.objFaxServer.OnOutgoingJobChanged +=new IFaxServerNotify_OnOutgoingJobChangedEventHandler(objFaxServer_OnOutgoingJobChanged);

objcsFax.objFaxServer.OnServerShutDown +=new IFaxServerNotify_OnServerShutDownEventHandler(objFaxServer_OnServerShutDown);

objcsFax.objFaxServer.OnOutgoingJobRemoved +=new IFaxServerNotify_OnOutgoingJobRemovedEventHandler(objFaxServer_OnOutgoingJobRemoved);

ArrayList Values = new ArrayList();

string [] Files = Directory.GetFiles("C:\\FaxDrop\\","*");//give me everything in this directory...

for(int i=0;i<Files.Length;i++)

{

FileName = Files;

Values.Add(i);


//Set the fax body
objcsFax.objFaxDocument.Body = FileName;;

//Name the document
objcsFax.objFaxDocument.DocumentName = "C#.NET Fax widget";

//Set the fax priority
objcsFax.objFaxDocument.Priority = FAXCOMEXLib.FAX_PRIORITY_TYPE_ENUM.fptHIGH;

//Add the recipient with the fax number 12225550100
objcsFax.objFaxDocument.Recipients.Add("999-9999","Joe Dirt");

//Choose to attach the fax to the fax receipt
objcsFax.objFaxDocument.AttachFaxToReceipt = true;

//Set the cover page type and the path to the cover page
objcsFax.objFaxDocument.CoverPageType = FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptSERVER;

objcsFax.objFaxDocument.CoverPage = "generic";


//Provide the cover page note
objcsFax.objFaxDocument.Note = "Test C# Fax Server";

//Specify that the fax is to be sent at a particular time
objcsFax.objFaxDocument.ScheduleTime = DateTime.Now;

objcsFax.objFaxDocument.Subject = "Today's fax";

//Set the sender properties.
objcsFax.objFaxDocument.Sender.Name = "cs Fax Server";
objcsFax.objFaxDocument.Sender.City = "Cucamonga";
objcsFax.objFaxDocument.Sender.State = "California";
objcsFax.objFaxDocument.Sender.Company = "Bugs Bunny";
objcsFax.objFaxDocument.Sender.Country = "USA";
objcsFax.objFaxDocument.Sender.Email = (e-mail address removed);
objcsFax.objFaxDocument.Sender.FaxNumber = "999-9999";
objcsFax.objFaxDocument.Sender.OfficeLocation = "CA";
objcsFax.objFaxDocument.Sender.OfficePhone = "999-9999";
objcsFax.objFaxDocument.Sender.StreetAddress = "1313 Mocking Bird Ln.";
objcsFax.objFaxDocument.Sender.ZipCode = "12345";
objcsFax.objFaxDocument.Sender.Department = "BB - Fax";

//Save sender information as default
objcsFax.objFaxDocument.Sender.SaveDefaultSender();

//Submit the document to the connected fax server.
objcsFax.JobID = objcsFax.objFaxDocument.ConnectedSubmit(objcsFax.objFaxServer);

}//end for

}

catch (Exception ex)
{
throw (ex);
}
}

private static void objFaxServer_OnOutgoingJobAdded(FaxServer pFaxServer, string bstrJobId)
{
MessageBox.Show("JobID: " + bstrJobId + "Added to queue");
}

//This event receives the FaxJobStatus object
private static void objFaxServer_OnOutgoingJobChanged(FaxServer pFaxServer, string bstrJobId, FaxJobStatus pJobStatus)
{
MessageBox.Show(Convert.ToString(pJobStatus.Status));
}

//Should be raised when fax is sent and is currently not...
private static void objFaxServer_OnServerShutDown(FaxServer pFaxServer)
{
MessageBox.Show("Fax Done");
}

private static void objFaxServer_OnOutgoingJobRemoved(FaxServer pFaxServer, string bstrJobId)
{
MessageBox.Show("Job Removed");
}

}

}
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top