Trouble with C# and FAXCOMEXLib: Fax Service Extended COM API

  • 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

L

Loganatr [MSFT]

Change all your delegation handler to public

--
Loganatr [MSFT]
Microsoft Printing, Imaging and Fax Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.'



Patrick Kenney via AdminLife said:
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");
}

}

}
 
Joined
Nov 21, 2005
Messages
1
Reaction score
0
Hello, I ask some question.

I use the FAXCOMEX.dll at XP, the program can run. but when I run at Win2K, the program catch an Exception -- System.Runtime.InteropServices.COMException (0x80040154): COM object with CLSID {FA21F4C6-5C4C-11D1-83CF-00C04FB6E984} is either not valid or not registered.

could you help me? thank you!
 
Ad

Advertisements

Joined
Feb 17, 2006
Messages
3
Reaction score
0
Hi DavidLv


You must register your COM dll with "regsvr32" dll on your W2K and it would be fine (just type : regsvr32 "C:\xxx\xxx\mydll.dll")

=========================================================

About me, i have a trouble with the FAXCOMEXLib. Actually I am no able to send any document on local or distant server.

If i use the standard FAXCOMLib it works fine on local server, but not on the remote server.

I have installed the fax service on both.

When I connect to the server I use : @\\MyServer

I always get: Connection to server failed.

I have no FireWall.

Here is my FAXCOMEXLib C# code:


LOCAL:


FAXCOMEXLib.FaxServerClass fsc = new FAXCOMEXLib.FaxServerClass();



fsc.Connect("") ;

FAXCOMEXLib.FaxDocumentClass fd =
new FAXCOMEXLib.FaxDocumentClass() ;

fd.DocumentName = "test" ;

fd.Recipients.Add("005455964454","MyName") ;

fd.Sender.Name = "Me" ;

fd.Sender.FaxNumber = "00545556123" ;

fd.Body = @"C:\temp\test.doc" ;

//fd.ConnectedSubmit(fsc) ;

fd.Submit("") ;






SERVER:


FAXCOMEXLib.FaxServerClass fsc = new FAXCOMEXLib.FaxServerClass();



fsc.Connect(@"\\192.168.0.3") ;

FAXCOMEXLib.FaxDocumentClass fd =
new FAXCOMEXLib.FaxDocumentClass() ;

fd.DocumentName = "test" ;

fd.Recipients.Add("005455964454","MyName") ;

fd.Sender.Name = "Me" ;

fd.Sender.FaxNumber = "00545556123" ;

fd.Body = @"C:\temp\test.doc" ;

//fd.ConnectedSubmit(fsc) ;

fd.Submit(@"\\192.168.0.3") ;



Can you help me please?

What is more important to me is to make out with the server...
 

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