Option Compare Database
Public Fax As String
Public FaxUser As String
Public FaxPwd As String
Public Function SendFax(RptName As String, FaxNo As String, Optional strLinkCriteria As String = "") As Long
If UCase(Fax) = "INTERFAX" Then
If FaxUser = "" Or FaxPwd = "" Then
MsgBox "Fax username and/or password missing from dealtrak configuration", "", "DealTrak"
Exit Function
End If
If Not strLinkCriteria = "" Then
DoCmd.OpenReport RptName, acViewDesign
Reports(RptName).FilterOn = True
Reports(RptName).Filter = strLinkCriteria
End If
Dim tmpRpt As String
tmpRpt = "c:\dealtrak\tmp_" & Format(Now, "yyyymmddhhnnss") & ".snp"
DoCmd.OutputTo acOutputReport, RptName, acFormatSNP, tmpRpt
' Load snapshot as base64binary
Dim img() As Byte
Open tmpRpt For Binary Access Read Lock Read As #1
ReDim img(LOF(1) - 1) 'Keep enough space to read the entire file to memory
Get #1, , img
Close #1
If Not strLinkCriteria = "" Then DoCmd.Close acReport, RptName, acSaveNo
Kill tmpRpt
Dim Success As Double
Dim interfax As New clsws_InterFax
Success = interfax.wsm_Sendfax(FaxUser, FaxPwd, ConvertPhoneIntFormat(FaxNo), img, "SNP")
If Success > 0 Then
MsgBox "Fax sent successfully.", , "DealTrak"
Dim Method As String
Method = "Interfax"
MySQL_Query "INSERT into tblSMSLog SET" & _
" Message = " & MyData(Method) & _
",SentTo = " & MyData(FaxNo) & _
",DateSent = Now()"
Else
MsgBox "Fax not sent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
End If
SendFax = CLng(Success)
Else
Dim objWFSend As New WFSendClass
Dim lngReturn As Long, strFaxError As String
Dim FinanceFaxNo As String
With objWFSend
.HoldFax = False
.FaxReport RptName
.FaxDial FaxNo
.FaxRecipient "", ""
lngReturn = .SendFax(True, , True) 'Delete the fax event after send
If lngReturn <> True Then
strFaxError = .TranslateFaxError(lngReturn)
Debug.Print strFaxError
End If
End With
Set objWFSend = Nothing
SendFax = 0
End If
End Function
Function FaxQuery(Optional ShowActiveOnly As Boolean = False, Optional Show As Integer = 50) As struct_FaxItemEx()
Dim FaxItems() As struct_FaxItemEx
Dim interfax As New clsws_InterFax
Dim ResultCode As Long
If ShowActiveOnly Then
FaxItems = interfax.wsm_FaxQuery(FaxUser, FaxPwd, "ACTIVE", "", -1, ResultCode)
Else
FaxItems = interfax.wsm_FaxQuery(FaxUser, FaxPwd, "GT", "0", Show, ResultCode)
End If
If ResultCode < 0 Then
MsgBox "Fax service error code: " & InterFaxErrorCodes(CInt(ResultCode)), , "DealTrak"
End If
FaxQuery = FaxItems
End Function
Function ReSendFax(FaxID As String, FaxNumber As String) As Long
Dim Success As Double
Dim interfax As New clsws_InterFax
Success = interfax.wsm_ReSendFax(FaxUser, FaxPwd, FaxID, FaxNumber)
If Success > 0 Then
MsgBox "Fax ReSent successfully.", , "DealTrak"
Else
MsgBox "Fax not ReSent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
End If
ReSendFax = CLng(Success)
End Function
Function InterFaxErrorCodes(ErrorCode As Integer) As String
Select Case (ErrorCode)
Case -112
InterFaxErrorCodes = "No valid recipients added or missing fax number"
Case -123
InterFaxErrorCodes = "No valid documents attached"
Case -150
InterFaxErrorCodes = "Internal System Error"
Case -1002
InterFaxErrorCodes = "Number of types does not match number of document sizes string"
Case -1003
InterFaxErrorCodes = "Authentication error"
Case -1004
InterFaxErrorCodes = "Missing file type"
Case -1005
InterFaxErrorCodes = "Transaction does not exist"
Case -1007
InterFaxErrorCodes = "Size value is not numeric or not greater than 0"
Case -1008
InterFaxErrorCodes = "Total sizes does not match filesdata length"
Case -1009
InterFaxErrorCodes = "Image not available (may happen if the 'delete fax after completion' feature is active)"
Case -1030
InterFaxErrorCodes = "Invalid Verb or VerbData"
Case -3001
InterFaxErrorCodes = "Invalid MessageID"
Case -3002
InterFaxErrorCodes = "From parameter is larger than image size"
Case -3003
InterFaxErrorCodes = "Image doesn't exist"
Case -3004
InterFaxErrorCodes = "TIFF File Is Empty"
Case -3005
InterFaxErrorCodes = "Chunk size is smaller than 1"
Case -3006
InterFaxErrorCodes = "Max item is smaller than 1"
Case -3007
InterFaxErrorCodes = "No permission for this action (In inbound method GetList, LType is set to AccountAllMessages or AccountNewMessages, when the username is not a Primary user)"
Case Else
InterFaxErrorCodes = "Unknown Error"
End Select
End Function
Function FaxStatusCodes(StatusCode As Integer) As String
Select Case StatusCode
Case -1
FaxStatusCodes = "Rendering"
Case -2
FaxStatusCodes = "In-Queue"
Case -3
FaxStatusCodes = "Sending"
Case -22
FaxStatusCodes = "On Hold"
Case 0
FaxStatusCodes = "Sent"
Case 3072
FaxStatusCodes = "Error"
Case 3224
FaxStatusCodes = "No Response"
Case 3912
FaxStatusCodes = "No Tone"
Case 3931
FaxStatusCodes = "Busy"
Case 3935
FaxStatusCodes = "No Answer"
Case 3936
FaxStatusCodes = "Voice Answer"
Case 3937
FaxStatusCodes = "Rings Busy"
Case 6017
FaxStatusCodes = "Busy"
Case 6018
FaxStatusCodes = "No Answer"
Case 8021
FaxStatusCodes = "No Answer"
Case 8025
FaxStatusCodes = "Busy"
Case Else
FaxStatusCodes = "Error"
End Select
End Function