Solved

Fax Module ActiveX DLL Server 2003

Posted on 2006-11-12
33
689 Views
Last Modified: 2008-01-09
We have a legacy ASP web app that we have migrated to server 2003 STD.  All has gone well minus the fact that the fax module DLL does not work properly.  We have the source code and I realized it was using the old fax com object that is now the extended fax com object under 2003.  I have rebuilt the DLL a couple of times now using the extended com object but have had no luck.  I think it may also have to do with the fact that

1: I am coding the new DLL under VS2005 (.NET v2)
2: I'm not sure if there is anytthying in particular I have to do to make a DLL an ActiveX DLL.

It has been years since I have coded in any language and even then I wasn't really doing anything worth mentioning.  ;)  Any help would be greatly appreciated.  I am going to post the source from the original as maybe I am just going about this all the wrong way.

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

Function SendDocByFax(FDoc, FServer, FNumRecip, FRecip, FNumSend, FCov, _
                        FFNumSend, FComp, FAddr1, _
                        FAddr2, FAddr3, FSend, _
                        FSubj, FNote) As String

    On Error GoTo Ferr
    Dim FaxServer As Object
    Dim FaxDoc As Object
    Dim faxStatus As String
   
   
    Set FaxServer = CreateObject("FaxServer.FaxServer")
    faxStatus = "Create Object"
   
    FaxServer.Connect (FServer)
    faxStatus = "FaxServer.Connect"
   
    Set FaxDoc = FaxServer.CreateDocument(FDoc)
    faxStatus = "CreateDocument"
   
    If FCov = True Then     'Decide if a coverpage will be sent
        FaxDoc.SendCoverpage = 1
    Else
        FaxDoc.SendCoverpage = 0
    End If
   
    If FAddr1 <> "" Then    'Iterate to send up to three address lines
        FaxDoc.SenderAddress = FAddr1 & Chr(13)
    End If
    If FAddr2 <> "" Then
        FaxDoc.SenderAddress = FaxDoc.SenderAddress & FAddr2 & Chr(13)
    End If
    If FAddr3 <> "" Then
        FaxDoc.SenderAddress = FaxDoc.SenderAddress & FAddr3
    End If
   
    FaxDoc.ServerCoverpage = 1  'Coverpage on server rather than client
    FaxDoc.CoverpageName = "OMS.cov"
    faxStatus = "Coverpage"
   
    FaxDoc.SenderCompany = FComp
    FaxDoc.SenderFax = FFNumSend
    FaxDoc.SenderOfficePhone = FNumSend
    FaxDoc.SenderName = FSend
    FaxDoc.CoverpageSubject = FSubj
    FaxDoc.CoverpageNote = FNote
    FaxDoc.RecipientName = FRecip
    FaxDoc.FaxNumber = FNumRecip
    FaxDoc.Send
    faxStatus = "Send"
       
    Set FaxDoc = Nothing
   
    FaxServer.Disconnect
   
    Set FaxServer = Nothing
    SendDocByFax = "OK"
   
Ferr:
    SendDocByFax = Err.Description & "  " & faxStatus
   
End Function

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

Thanks!
0
Comment
Question by:Dm32z
  • 17
  • 16
33 Comments
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17930345
Well, for starters the Extended FAX object has changed names, it is not Set FaxServer = CreateObject("FaxServer.FaxServer"), but
Set FaxServer = CreateObject("FAXCOMEXLib.FaxServer"),

Furthermore, it will help coding easier if you use early binding instead of late binding, e.g.
Dim FaxServer As New FAXCOMEXLib.FaxServer

Here are the salient bits of code from one of my apps that uses the extended fax server.  I don't use all the parameters you need, but once you get the basics, you should be able to add in the rest.  Look to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/fax/faxinta_n_7e05.asp and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/fax/faxinta_n_3md0_cpp.asp

Dim svrex As New FAXCOMEXLib.FaxServer
Dim FaxEx As FAXCOMEXLib.FaxDocument

                svrex.Connect "<Your server machine name>"

                Set FaxEx = New FAXCOMEXLib.FaxDocument

                FaxEx.Body = "<Your printable file name>" 'FDoc I presume
                FaxEx.DocumentName = "<Your printable file name>" 'This is so it shows up in the fax console with a nicer name

                FaxEx.Recipients.Add "<Your phone number with dialing codes>" , "<Pretty Name for REcip>"' FRecip, FNumRecip

                'If you want a reciept
                FaxEx.ReceiptAddress = "EmailAddress for receipt"
                FaxEx.ReceiptType = frtMAIL
                FaxEx.AttachFaxToReceipt = True
                FaxEx.ScheduleType = fstDISCOUNT_PERIOD 'I do this to control when the fax will be sent

                FaxEx.ConnectedSubmit svrex
                Set FaxEx = Nothing


0
 
LVL 1

Author Comment

by:Dm32z
ID: 17930762
Tell me what you think about what I did before, maybe I am just coding in the studio.  I'm thinking that my problems may be that I am using Visual Studio 2005 and it is compiling in .Net v2 and the ASP web app doesn't like it.  Can the extended COM object be used under VB 6?

Here is my code:

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

   Function SendDocByFax(ByVal FDoc, ByVal FServer, ByVal FNumRecip, ByVal FRecip, ByVal FNumSend, ByVal FCov, ByVal FFNumSend, ByVal FComp, ByVal FAddr1, ByVal FAddr2, ByVal FAddr3, ByVal FSend, ByVal FSubj, ByVal FNote) As String

        On Error GoTo Ferr
        Dim objFaxDocument
        Dim objFaxServer
        Dim objSender As FaxSender.Class1
        Dim JobID As Object
        Dim faxStatus As String

        objFaxDocument = CreateObject("FAXCOMEX.FaxDocument")
        objFaxServer = CreateObject("FAXCOMEX.FaxServer")
        faxStatus = "Create Object"

        'Connect to the fax server
        objFaxServer.Connect(FServer)
        faxStatus = "Connected to Fax Server"

        'Set the fax body
        objFaxDocument.Body(FDoc)
        faxStatus = "Create Document"

        'Add the recipient with the fax number
        objFaxDocument.Recipients.Add(FNumRecip, FRecip)

        'Choose to attach the fax to the fax receipt
        objFaxDocument.AttachFaxToReceipt = False

        'Set the cover page type and the path to the cover page
        objFaxDocument.CoverPageType = 2
        objFaxDocument.CoverPage = "OMS.cov"

        'Provide the cover page note
        objFaxDocument.Note = FNote

        'Set Fax Subject
        objFaxDocument.Subject = FSubj

        'Set the sender properties.
        objFaxDocument.Sender.Name = FSend
        objFaxDocument.Sender.Company = FComp
        objFaxDocument.Sender.FaxNumber = FFNumSend
        objFaxDocument.Sender.OfficePhone = FNumSend
        objFaxDocument.Sender.StreetAddress = "123 Main Street"
        objFaxDocument.Sender.TSID = "Omega Home Builders fax daemon"

        'Iterate address lines
        If FAddr1 <> "" Then
            objFaxDocument.Sender.Address = FAddr1 & Chr(13)
        End If
        If FAddr2 <> "" Then
            objFaxDocument.Sender.Address = objFaxDocument.Sender.Address & FAddr2 & Chr(13)
        End If
        If FAddr3 <> "" Then
            objFaxDocument.Sender.Address = objFaxDocument.Sender.Address & FAddr3
        End If

        'Save sender information as default
        objFaxDocument.Sender.SaveDefaultSender()

        'Submit the document to the connected fax server
        'and get back the job ID.

        JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
        faxStatus = "Send"

        objFaxServer.Disconnect()
        SendDocByFax = "OK"


Ferr:
        SendDocByFax = Err.Description & "  " & faxStatus

    End Function

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

I understand what you are saying about binding, and I'll switch that.  Thanks.  Is there anything I need to do special to this VB code to make it able to work when called from an ASP web app?

Thank you for helping a code newb like me.  ;)
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17931488
My fax app using the Extended FAX object is in VB6.  I haven't done it from .Net 2005, but I recall you must have interop compatibility turned on to use ActiveX com objects, and probably want to add them as a reference to your project.  


What kind of errors do you get?
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17941871
Sorry for the slow response.  Here is the error code I get:


error '800401f9'


The line of code in the ASP that calls the function is:

================
    arrName = Split(Request.Form("fnName"),"||")
    arrFax = Split(Request.Form("fnFax"),"||")
    Set objFax = CreateObject("FaxSender.Class1")
    For i=1 To UBound(arrName)
      rc = objFax.SendDocByFax(phyFile,Application("srvName"),arrFax(i),arrName(i),sPh,cvr,SFax,SCo,SA1,SA2,SA3,SName,Request.Form("rdtSubj"),Request.Form("rdtMessage"))
      If rc <> "OK" Then
      errStatus = True
      Exit For
      End if

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

Thank you.
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17947251
Ha, 800401F9 has one of the most useless descriptions, "Error in the DLL."

Does it work if you call it from a non-ASP app?

About the only thing I could suggest is to start your DLL in the debugger and step through it to find what is causing the problem.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17947812
Ok, I got past all those initial issues.  I hadn't imported the library.  Now though I'm getting a new error.  Am I right in my thinking that since I'm coding in visual studio 2005 (.net ) I don't need to register the DLL.  Cause when I attempt to it tells me it can't create the entry point.  The error I'm getting now is:


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

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'FaxSender.Class1'

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


Any help is greatly appreciated.  Thanks.
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17948083
800a01ad is the COM DLL is missing components.  Are you getting this error on your development machine?

>>I don't need to register the DLL
If you compile on the machine, you don't need to.  If you deploy on a different machine, you do need to have the .net framework installed and Interop libraries on the target computer (they are needed to wrap the .net DLL in an ActiveX component)  see http://msdn2.microsoft.com/en-us/library/fh1h056h(VS.80).aspx

You also need to check "Register for COM interop" in the .net project compile settings, but I believe you already did that or you wouldn't be this far.  see also http://msdn2.microsoft.com/en-us/library/kew41ycz(VS.80).aspx and http://msdn2.microsoft.com/en-us/library/8877bdk6(VS.80).aspx



0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17948105
>>when I attempt to it tells me it can't create the entry point.

The DLL created by .net is not a COM dll but a .net managed code library, the Interop libraries wrap the dll to make it work like a COM dll, but as you found out, you can't register the dll itself.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17948543
I read through the articles.  Can you give me an example of what they are after, I don't think I'm grasping it.  Bare with me as I said I am newbish. ;)
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17949282
Basically they describe how .Net Interop supports COM interfaces, although I haven't done much of that, my understanding is
A) .Net has to be installled on your target computer.
B) The resulting DLL is NOT an ActiveX dll, but a .net assembly
C) There are things you can do in .Net that will not work in COM, such as polymorphic interfaces,  e.g. in .net you can have the same method name with different parameter lists, but not in COM
D) When you choose "Register for COM Interop", you will get a .tlb you can use as the type library in ActiveX languages.

I believe you may also have to use the regasm tool in .net once on the target computer to let the interop libraries know what .net dll to register as COM.  If you look in the registry for a .net COM Interop, you will find that the the dll registered is not actually the dll you built, but one of the .net dlls, and there are extra parameters that tell that dll where to find your dll.

Are you getting the error on your development machine or a deployment machine?
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17949336
Deployment.  The dev machine sadly is just me with VS 2005.  I don't have the entire ASP app on my machine.  I know this would probably make it easier to say.  I have however now found the option inside VS 2005 and have the tlb file.  And your saying I need to to what with it.  Also on these files it makes in the /bin folder after I recompile.  Maybe I'm not putting those in the right location on the deployment machine.  

The files are:

FaxSender.dll
FaxSender.tlb  (just now got that one)
FaxSender.xml
fxscomexLib.dll




My question I'm wondering is of those files, what all have to go over to the deployment machine.  Does the fxscomexLib.dll need to also go?  Inside my project it is tagged as copy local so that makes me think it does not.  Does the xml need to move over as well?  Also on the fxscomexLib.dll file, if it does need to get copied over, does it need to be in the same file structure location as it is in the project references.  I sure do appreciate all the help!
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17950776
>>Deployment

Ok, that makes more sense.  Whip up a little app on your machine to test that it does work under ASP and save some headaches.

For the deployment machine, have a look in your registry to find your class library, then look on the target machine to see if it has the same entries.  If it is missing on the target machine (assuming it has .net already installed and the same release level as you), use the regasm tool to register your .net dll.  Regasm lives withing the windows folder.  Use the /tlb switch.  It basically is the same as regsvr32, but for com interop .net dlls  do "regasm youdll.dll /TLB"
with the appropriate paths of course.

>>Maybe I'm not putting those in the right location on the deployment machine.  
That is what regasm is for, it defines the location.
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17950828
BTW, fxscomexLib.dll  IS an ActiveX dll, and thus gets registered in the normal way I think.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17952670
Ok, I moved over the four files and used the regasm to register my .net dll.  fxcomexLib.dll gives me the same entry point message with i try to register.  I am still getting the same message when i try to run in from within the asp app.  I'm going to see if I can work up something in asp to make sure I am not just fighting a losing battle here.  


After I did the Regasm which came back successful was there anything else I needed to do.  Thanks for the help.  
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17955385
>> fxcomexLib.dll gives me the same entry point message with i try to register.

Now I'm wondering if the problem is not your control, but the fax client itself.  I've not tried to manually register it, I usually go to the machine and add the fax server as a printer.  Perhaps there is some other setup that the faxserver client must do that you are not doing.  So that is worth a try.

>>I'm going to see if I can work up something in asp to make sure I am not just fighting a losing battle here.  
It is always a good idea to make sure your stuff works in a test environment before deploying.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17956587
On the test machine I am getting this in the event log.  It could be my asp code causing it as well.


Failed to execute request because the App-Domain could not be created. Error: 0x80131902
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17960308
Did you try installing the fax-printer on your local machine too?  Can you send a fax?
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17978189
I moved the entire project back to VB 6.  I have the DLL compiled and with error checking and log files now have the DLL going all the way to the connect submit where it litterally just times out.  The command that runs but just sits there is:

JobID = objFaxDocument.ConnectedSubmit(objFaxServer)



Once it submits the asp just sits and eventually times out.  Never even drops to the error code.  
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17978362
I can see that notepad.exe fires up under the Network Service, but never closes and the DLL just hangs.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17979449
Yea that is pretty much what happens.  I have reinstalled fax services, but it keeps doing the exact same thing.  I have also stubled across other posts on the internet with this issue, but yet to have any resolutions.  It is like it works and as soon as it submits, fires up notepad to read the document it hangs while notepad is open.  Eventually the asp calling the DLL times out.  Any help is greatly appreciated.  
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17980709
The fax client uses the app associated with the file suffix that you attach as the fax body.  I believe it uses the "print" action for the file association, just as double-clicking the file uses the "open" action, e.g. it does nearly the same thing as right-clicking on a document and choosing "Print" instead of open.  It "prints" to a special printer drive that converst it into a TIF, which the fax server uses for all faxes.  Since it is opening notepad, I assume you are attaching a text document.  

Can you fax the same document using the fax-printer from your machine?  

Can you right click the source document and choose "print", it should go to your default printer when you click on it.

Can you send a different document type?  Like Excel or Word?
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17981382
Does the fax printer off the server need to be installed on all client machines that will use the asp app?
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17981860
>>Does the fax printer off the server need to be installed on all client machines that will use the asp app?

Yes.  It might be possible to install it and then remove it, however, if you don't want them to see it.  I never tried that.  Or install it as administrator.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17997325
I have installed the printer on the client stations but still having the exact same issue.  I send the job and notepad it fired up on the server and just sits there.  
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17997618
Can you use the fax printer on the client station to fax?  e.g. not using your app, just testing that the fax services work?
0
 
LVL 1

Author Comment

by:Dm32z
ID: 17997892
Yes.
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 500 total points
ID: 17998409
hmm, OK, I copied your code, and had to fix some things, but the resulting minimal test functionality worked.  Things I had to change are: JodID is a variant, not an object, function calls which don't return values don't use () in VB6, e.g. "objFaxServer.Connect FServer", not "objFaxServer.Connect(FServer)".  And I declared objFaxDocument and objFaxServer using early binding (though this shouldn't make any functional difference, just easier to code).  Here is my result which worked.  I commented out all the other stuff like name and address.



Function SendDocByFax(ByVal FDoc, ByVal FServer, ByVal FNumRecip, ByVal FRecip, ByVal FNumSend, ByVal FCov, ByVal FFNumSend, ByVal FComp, ByVal FAddr1, ByVal FAddr2, ByVal FAddr3, ByVal FSend, ByVal FSubj, ByVal FNote) As String

        Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
        Dim objFaxServer As New FAXCOMEXLib.FaxServer
       
        Dim JobID As Variant
        Dim faxStatus As String

        'Connect to the fax server
        objFaxServer.Connect FServer
        faxStatus = "Connected to Fax Server"

'        'Set the fax body
       
        objFaxDocument.Body = FDoc
        faxStatus = "Create Document"

        'Add the recipient with the fax number
        objFaxDocument.Recipients.Add FNumRecip, FRecip

        JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
        faxStatus = "Send"

        objFaxServer.Disconnect
        SendDocByFax = "OK"
    End Function
0
 
LVL 1

Author Comment

by:Dm32z
ID: 18009264
I scrapped down my code to just send the test text file and even hard coded in the number and name into the DLL.  Regardless all it does is just call up notepad and sit there.  I keep thinking there is something in the enviroment that is leading to this as I keep coming across other posts on the net with people having this same issue.  All this box has on it is SQL & IIS.  Other then that it is a fresh box.  
0
 
LVL 1

Author Comment

by:Dm32z
ID: 18009529
If I take out the document call then it will send a cover page only just fine.  
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 18019192
My fax server is running SQL & IIS also, but no problems.  I do not fax text documents, mostly pdf's.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 18024370
Is it also 2003?  Maybe I am having some sort of rights issue.  I'm going to try a pdf and see if it is just maybe the text file problem.
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 18027797
Yes 2003 server.
0
 
LVL 1

Author Comment

by:Dm32z
ID: 18041857
You have certainly answered my question I began with it has just snowballed into many more issues.  I have come across 6 other instances on the net of people having the exact same issue now as I.  I want to go ahead an award you the points you have most certainly earned.  I'm going to start a new post on this specific final issue I am having in the hopes someone mite have an idea or a direction to go to attach it.  Thank you for all your patient and knowledge.  
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now