Fax Software

Community Forums

This topic contains 14 replies, has 0 voices, and was last updated by  Anonymous 14 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #2727

    Anonymous

    A lot of people run into this problem and it can be solved by waiting for a return entry id from WinFax. In VB, here is how you would do this:

    ##other code …####

    RetCode = objWinFaxSend.AddRecipient()
    RetCode = objWinFaxSend.SetPrintFromApp(1)
    RetCode = objWinFaxSend.Send(1)
    RetCode = objWinFaxSend.ShowSendScreen(0)

    ‘ this routine waits until “IsReadyToPrint” returns a Non-zero
    ‘ value (ready)
    ‘ this loop will wait but allow background
    ‘ processing to continue

    Do While objWinFaxSend.IsReadyToPrint = 0
    DoEvents
    Loop

    ###Here we print the document to the WinFax PRO printer driver#####

    ‘ Wait until the EntryID is ready before moving on.
    ‘ the Send(1) you specified before is used here.
    ‘ We don’t care what the EntryID is,
    ‘ we just want to know that is it ready.
    ‘ this loop will wait but allow background processing to continue
    ‘ when ready IsEntryIDReady is not = to 1

    Do While objWinFaxSend.IsEntryIDReady(0) <> 1
    DoEvents
    Loop

    Hope this helps,

    #4651

    Anonymous
    Member

    What factors account for how long it takes for IsEntryIDReady(0) to return with a zero. On my machine sometimes it take a very long time (Over 10 mins.)

    #4652

    Anonymous

    Hi BMCMICKLE,
    It is definitely not normal.

    Are you sure you have used Send(1) ? perhaps your log structure is corrupted. You can try rebuilding the logs using the rebuild.bat option in the WinFax directory, or wipe out your status*.* files completely from your DATA directory (but remember, this will wipe out all your logs) it is a good way to force WinFax to recreate a new set of log files. (Do this only when WinFax is already shut down)

    #4653

    Anonymous
    Member

    The problem is related to the SetPrintFromApp(1) command. When I remove it to match some of the samples, (see vb6 code samples) the code processes quickly. If I include it like other examples, the code (mainly VBA sample) seems to hang. The use of SetPrintFromApp(1) in my mind is to print to the Winfax print driver. If I’m using the COM object the why do I need to use the print driver? Then the question is do I need the IsReadyToPrint call if I’m not using the print driver? Our customer is getting the send dialog with code that does not us SetPrintFromApp(1) command. Thank you in advance for any help.

    #4654

    Anonymous

    SetPrintFromApp(1) should only be used if you are going to be using the WinFax PRO printer driver to generate a fax. If you are just sending a cover page, and/or adding an attachment then this function should not be used. You can also remove the .IsReadyToPrint code, as it is not required.

    If you plan to use SetPrintFromApp(1), you must include code that actually prints to the WinFax PRO printer driver. Check out the Word 2000 sample code at
    http://www.getfaxing.com/cgi-bin….topic=4
    and you will see how the printing is accomplished before waiting for the EntryID.
    Hope that helps

    #4655

    Anonymous

    I just realized that my comments in my original message (with the code) didn’t appear in the message! It looks like this bulletin board ignores text within “<" quotes. I replaced them with ### instead and it appears. I believe it is because the board thinks its part of HTML. I edited the message, and this time made sure the comments appear properly.

    #4656

    Anonymous
    Member

    Thank you for your last message. If I could ask a followup question. Our program faxes invoices and statements to the users customers. So that is just a cover page and an invoice/statement. Therefore I should not use the printer driver. My question is which of the following methods should I uses when I’m only using the COM object and not the print driver:
    IsEntryIDReady(0)
    LeaveRunning()
    ShowSendScreen(0)
    SetDeleteAfterSend(1)
    SetTypeByName(“FAX”)
    It maybe some work for both.

    Thank you again.

    #4657

    Anonymous

    You should still use IsEntryIDReady if you are attaching files (because they still have to be printed to the WinFax PRO printer driver) I a**ume your invoice is in some sort of format (ASCII file?, Word document etc?)

    IsEntryIDReady – recommended you use this along with Send(1) when attaching and/or printing to the WinFax pro printer driver.
    LeaveRunning – controller is left active after you are done. Required — if you terminate the SendObject, your fax will not send.
    ShowSendScreen(0) – send screen does not appear, this is default setting. Optional
    SetDeleteAfterSend(1) – only if you want to delete the fax files after they are sent. Optional
    SetTypeByName(“FAX”) – default setting, not required…only used if your application has other methods to send a fax (such as Internet Fax)
    (Optional)

    Let me know if you have any questions.

    #4658

    Anonymous
    Member

    I have implemented the IsReadyToPrint delay loop like the example code shows. However the customer says the problem of the send dialog popuping up for each send is still there. Is there any thing else that might correct this behavior?

    #4659

    Anonymous
    Member

    Post your code, as it is likely something to do with timing or the order of the functions

    #4660

    Anonymous
    Member

    This is the code we use. The information is read from a file. Thank you for looking at it. I tried to follow some of the examples.

    Private Sub SendWinFaxes()

    Dim attachsObj As Object
    Dim DocPath As String
    Dim SendObj As Object
    Dim Ret As Integer
    Dim ErrorCode As Long
    Dim FileNum As Integer
    Dim FaxNumber As String
    Dim Idx As Long
    Dim AreaCode As String
    Dim PhoneNumber As String
    Dim Countrycode As String
    Dim ReturnCode As Integer
    Dim colTestFiles As Collection
    Dim FilePath As Variant
    Dim StartTime As Single
    Dim TestTime As Single
    Dim PrinterObj As Printer
    Dim OriginalPrinter As String

    On Error GoTo SendWinFaxesError

    If FileLen(mvFaxControlFile) = 0 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocNoFaxControlFile
    End If

    If Not SendObj Is Nothing Then Set SendObj = Nothing
    ‘Instantiate Send Object
    Set SendObj = CreateObject(“WinFax.SDKSend”)
    SendObj.SetClientID (“Client Name”)

    If Not attachsObj Is Nothing Then Set attachsObj = Nothing

    Set attachsObj = CreateObject(“WinFax.Attachments”)

    If SendObj Is Nothing Then
    Err.Raise enmElectronicDocErrors.eElectronicDocWinProComponentNotFound
    End If

    If attachsObj Is Nothing Then
    Err.Raise enmElectronicDocErrors.eElectronicDocWinProComponentNotFound
    End If

    CleanupFaxTempFiles

    ‘— In order to pretest the control file for errors
    ‘— We will only activate the send on the second time
    ‘— through the loop.
    For Idx = 0 To 1

    ‘— Remember the files created on the test run and delete them
    ‘— before the real run.

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, ” Start time ” & Now()
    End If

    ‘— Clean up the files created on test run.
    If Idx = 0 Then
    Set colTestFiles = New Collection
    Else
    For Each FilePath In colTestFiles
    mvoFSO.DeleteFile FilePath
    Next
    Set colTestFiles = Nothing
    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, ” After deleting files – 2 ” & Now()
    End If
    End If

    FileNum = FreeFile()
    If FileNum = 1 Then FileNum = 8

    ‘Open the control file
    Open mvFaxControlFile For Input As FileNum

    If mvLogging Then
    If Idx = 0 Then
    WriteToLogFile “WinFaxLog.TXT”, ” *** Starting WinFax Test Run *** “
    Else
    WriteToLogFile “WinFaxLog.TXT”, ” *** Starting WinFax Transmitting Run *** “
    End If
    End If

    Do
    ‘Clear variables
    BlankProperties
    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, ” After BlankProperties ” & Now()
    End If

    ‘BlankProperties is called elsewhere so don’t add the following
    FaxNumber = “”
    AreaCode = “”
    mvFaxSendDate = “”
    mvFaxSendTime = “”
    mvFaxPriority = 2
    mvDocPath = “”
    PhoneNumber = “”

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, ” Before Input # Statement” & Now()
    End If

    ‘Read the fax control record into property variables
    Input #FileNum, mvDestinationType, mvDestinationID, _
    mvFaxNumber, mvFaxName, _
    mvFaxCompany, mvFaxCityState, _
    mvFaxSendDate, mvFaxSendTime, mvFaxPriority, mvMessage, _
    mvDocPath

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, “1st DocPath = ” & mvDocPath
    End If
    ‘— Copy the RTF file as a DOC file in a Temp directory, if needed as a Winfax work around.
    ‘— Note: Set mvUsingDocExtension to true for now. Later we can add a system configuration
    ‘— keyword that is set in FDCFG, if we need to be able to process files as RTF or DOC.
    mvUsingDocExtension = True

    If mvUsingDocExtension Then
    DocPath = mvDocPath
    mvDocPath = “”
    mvDocPath = CreateUniqueTempWinFaxFile(DocPath)
    End If

    If Idx = 0 Then colTestFiles.Add mvDocPath

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, ” 2nd DocPath when converted to temp dir = ” & mvDocPath
    End If
    ‘Load the properties of WinFax send object

    ‘ Countrycode
    ‘— When we support faxing to other countries, this will have to be changed
    ‘— At this time its not clear where it will be stored
    Countrycode = “1”

    If Countrycode <> “1” Then
    ReturnCode = 0
    ReturnCode = SendObj.SetCountryCode(Countrycode)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidCountryCode
    ReturnCode = 0
    End If
    End If

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, “Fax Number ” & mvFaxNumber
    End If

    ‘— Verify that the control file and the Attachment have the same phone number
    If Not CheckPhoneNumber() Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidAttachFile
    ReturnCode = 0
    End If

    ‘AreaCode
    If Len(mvFaxNumber) = 10 Then
    AreaCode = Left&#36(mvFaxNumber, 3)
    End If

    If Len(AreaCode) = 3 Then
    ReturnCode = SendObj.SetAreaCode(AreaCode)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidAreaCode
    ReturnCode = 0
    End If
    End If

    ‘PhoneNumber
    PhoneNumber = Right&#36(mvFaxNumber, 7)
    If Len(PhoneNumber) = 0 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidPhoneNumber
    End If

    ReturnCode = SendObj.SetNumber(PhoneNumber)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidPhoneNumber
    ReturnCode = 0
    End If

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, “Fax Number ” & mvFaxNumber
    WriteToLogFile “WinFaxLog.TXT”, “Area Code ” & AreaCode
    WriteToLogFile “WinFaxLog.TXT”, “Phone Number ” & PhoneNumber
    End If

    ‘ Leave running
    ReturnCode = SendObj.LeaveRunning()
    If ReturnCode = 1 Then
    If Ret <> 0 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocSendError
    End If
    End If

    ‘ Recipients name
    ReturnCode = SendObj.SetTo(mvFaxName)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidRecipient
    ReturnCode = 0
    End If

    ‘ Recipients company
    ReturnCode = SendObj.SetCompany(mvFaxCompany)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidCompany
    ReturnCode = 0
    End If

    ‘ Send Time
    If Len(“” & mvFaxSendTime) > 0 Then
    ReturnCode = SendObj.SetTime(CDate(mvFaxSendTime))
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidSendTime
    ReturnCode = 0
    End If
    End If

    ‘ Send date
    If Len(“” & mvFaxSendDate) > 0 Then
    ReturnCode = SendObj.SetDate(mvFaxSendDate)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidSendDate
    ReturnCode = 0
    End If
    End If

    ‘ Send Priority
    If Len(“” & mvFaxPriority) > 0 Then
    ReturnCode = SendObj.SetPriority(mvFaxPriority)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidPriority
    ReturnCode = 0
    End If
    End If

    ReturnCode = SendObj.SetResolution(1)
    If ReturnCode = 1 Then
    If Ret <> 0 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocSendError
    End If
    End If

    ‘Subject
    ReturnCode = SendObj.SetSubject(mvSubject)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidSubject
    ReturnCode = 0
    End If

    ‘ Delete after send so attachments collection does not grow too big.
    ReturnCode = SendObj.SetDeleteAfterSend(1)
    If ReturnCode = 1 Then
    If Ret <> 0 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocSendError
    End If
    End If

    ‘ Send Quick Cover
    ReturnCode = SendObj.SetQuickCover(1)
    If Len(“” & mvMessage) > 0 Then
    ReturnCode = SendObj.SetCoverText(mvMessage)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidQuickCover
    ReturnCode = 0
    End If
    End If

    ‘Attachment
    ReturnCode = SendObj.AddAttachmentFile(mvDocPath)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidAttachFile
    ReturnCode = 0
    End If

    ‘Add Recipent
    If SendObj.AddRecipient() = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocInvalidRecipient
    End If

    ‘— don’t send for the trial run idx = 0 just see if there are errors
    If Idx = 1 Then
    ‘ okay, lets go!
    Ret = SendObj.Send(1)
    ‘ was there an error?
    If Ret <> 0 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocSendError
    End If
    End If

    ‘— Suppress the popup screen
    If Idx = 1 Then
    ReturnCode = SendObj.ShowSendScreen(0)
    If ReturnCode = 1 Then
    Err.Raise enmElectronicDocErrors.eElectronicDocSendError
    ReturnCode = 0
    End If
    End If

    ‘— Wait Until EntryID is ready before moving on.
    If Idx = 1 Then

    StartTime = Timer
    Do While SendObj.IsEntryIDReady(0) <> 1
    DoEvents
    TestTime = Timer
    If TestTime >= (StartTime + 1200) Then
    Err.Raise enmElectronicDocErrors.eElectronicDocEntryIDReadyFailed
    End If
    Loop
    End If

    If mvLogging Then
    WriteToLogFile “WinFaxLog.TXT”, ” ===== Fax Sent to Fax Queue ====== ” & vbCrLf & vbCrLf
    End If
    ‘ destroy and recreate the send object so we can send another fax
    Set SendObj = Nothing
    Set SendObj = CreateObject(“WinFax.SDKSend”)
    SendObj.SetClientID (“Client Name”)

    Loop Until EOF(FileNum) = True

    Close #FileNum
    Next
    SendObj.Done
    Set SendObj = Nothing
    Set attachsObj = Nothing

    Exit Sub

    SendWinFaxesError:
    Close #FileNum
    mvErrorCode = SendObj.GetLastError()
    ‘ Set colTestFiles = Nothing
    Set SendObj = Nothing
    ErrorTrap “SendWinFaxes “
    Exit Sub
    Resume

    End Sub

    #4661

    Anonymous
    Member

    Thats a lot of code to review…i expect it is a problem with some of the for/next loops.
    you might want to hard code some of the data and see if you get the same problems

    #4662

    Anonymous
    Member

    Yeah I know it’s a lot of code. The For Next loop is to see if any error will trigger before sending. Sort of a dry run. The error log errors out after 20 mins in the Do While .IsEntryIdReady(o) <>1
    DoEvents
    Loop
    Before I put the break a 20 Mins it would sometimes go 40 mins +.
    Does modem pooling have any bearing on this? Should Winfax be reinstalled? Maybe the registry is messed up? They ran Rebuild.bat and sometimes have this same problem.

    Thanks

    #4663

    sistemi
    Member

    Although it is passed a long since this thread, I ‘ve the same problem.
    I’ve a windows 2000 PC’s SP4 and winfax PRO 10.0.
    I’ve developed a faxserver application, which start every X minutes every day. This works fine, except that every 2-3 days, the application hangs on the popup window . So, the next time my application starts, the winfax object is still locked, the word object can’t create a new fax, and all application crash. This is my code for sending fax:

    ‘**********************************
    Private Function SpedisciFax(rs As Recordset, PrenStr As String) As Boolean

    Dim t As Integer
    Dim OBJwinFAX As Object
    Dim hregkey As Long ‘ receives handle to the newly created or opened registry key
    Dim secattr As SECURITY_ATTRIBUTES ‘ security settings of the key
    Dim subkey As String ‘ name of the subkey to create
    Dim neworused As Long ‘ receives 1 if new key was created or 2 if an existing key was opened
    Dim Ntel As String ‘ the string to put into the registry
    Dim ID As Long ‘ the string to put into the registry
    Dim retval As Long ‘ return value

    On Error GoTo ErrExit

    ‘ Writing registry
    secattr.nLength = Len(secattr) ‘ size of the structure
    secattr.lpSecurityDescriptor = 0 ‘ default security level
    secattr.bInheritHandle = True ‘ the default value for this setting
    Ntel = Trim(ConvNull(rs!NUMERO_FAX))

    ID = Trim(rs!ID)
    Debug.Print ID

    namefile = “c:temp” & Trim(rs!ID) & “_” & Trim(rs!NUMERO_SINISTRO) & “.doc”

    WDoc.SaveAs FileName:=namefile, FileFormat:=wdFormatDocument, LockComments:=False, Password:=””, AddToRecentFiles:=True, WritePassword:=””, ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False

    ‘inserted by WinFaxPro
    Set OBJwinFAX = CreateObject(“WINFAX.SDKSEND8.0”)

    OBJwinFAX.SetNumber (Ntel)
    OBJwinFAX.setsubject (ID)
    OBJwinFAX.SetCompany (“Casa di cura”)
    OBJwinFAX.AddRecipient
    OBJwinFAX.AddAttachmentFile namefile
    OBJwinFAX.Send (0)

    ‘inserito dal WinFaxPro

    WDoc.Close wdDoNotSaveChanges
    WApp.Quit wdDoNotSaveChanges

    Set OBJwinFAX = Nothing

    Set WDoc = Nothing
    Set WApp = Nothing
    SpedisciFax = False
    Exit Function

    ErrExit:
    Call ScriviLog(“Errore nell’invio a WinFax: ” + Str$(Err))
    SpedisciFax = True

    End Function
    ‘**********************************

    I’ve tried several solutions
    (i.e.: I release the objwinfax after used; I don’t use in this PC Outlook, cause I know that this could generate problems; I’ve tried to increase the interval settings, i.e. to 1 hour and more…) but the problems still remains.
    Thank in advance for any help/suggestions
    Bye

    #4664

    Anonymous
    Member

    did you try send(1) and checking for the entryid to be ready before setting the winfax object to nothing?

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.