I have been playing with faxing for a while now and am disatified with the faxcom.dll that is available so i thought i would try the winfax.dll. I have managed to piece together the following code.
However when i run it i get the error code 87 which means
ERROR_INVALID_PARAMETER i think. The problem im having mainly is that the user defined type fax_job_param is incorrect as i dont know how to go about defining the sizeof the type. Everything else as far as i know is correct.
any help regarding this will be most appreciated thanks.
P.S. this is all the code except the form itself which only has one command button.
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type FAX_JOB_PARAM
SizeOfStruct As Long 'structure size, in bytes
RecipientNumber As String 'pointer to recipient's fax number
RecipientName As String 'pointer to recipient's name
Tsid As String 'pointer to transmitting station identifier
SenderName As String 'pointer to sender's name
SenderCompany As String 'pointer to sender's company
SenderDept As String 'pointer to sender's department
BillingCode As String 'pointer to billing code
ScheduleAction As Long 'job scheduling action code
ScheduleTime As SYSTEMTIME 'time to send fax
DeliveryReportType As Long 'e-mail delivery report type
DeliveryReportAddress As String 'pointer to e-mail address
DocumentName As String 'pointer to document name to display
CallHandle As Long 'reserved
Reserved(3) As Long 'must be zero
End Type
Const JSA_NOW = 0 'Send now Send the fax as soon as a device is available.
Const JSA_SPECIFIC_TIME = 1 'Send at specific time 'Send the fax at the time specified by the ScheduleTime member.
Const JSA_DISCOUNT_PERIOD = 2 'Send at server configured discount period 'Send the fax during the discount rate period. Call the FaxGetConfiguration function to retrieve the discount period for the fax server.
Const DRT_NONE = &H0 '// Do not send DR or NDR receipt to the sender of the fax transmission.
Const DRT_EMAIL = &H1 '// Send DR or NDR receipt by email
Const DRT_INBOX = &H2 '// send DR or NDR receipt to the sender's local personal folder store (PST).
Private Declare Function FaxConnectFaxServerA Lib "winfax.dll" ( _
ByVal MachineName As String, _
ByRef FaxHandle As Long) As Long
Private Declare Function FaxClose Lib "winfax.dll" ( _
ByVal FaxHandle As Long) As Long
Private Declare Function FaxSendDocumentA Lib "winfax.dll" ( _
ByVal FaxHandle As Long, _
ByVal filename As String, _
ByRef jobparams As FAX_JOB_PARAM, _
ByRef CoverpageInfo As Long, _
ByRef faxjobid As Long) As Long
Dim params As FAX_JOB_PARAM
Dim stime1 As SYSTEMTIME
Dim filename As String
Private Sub Command1_Click()
Dim FaxHandle As Long
Dim faxjobid As Long
filename = "c:\currfax.tif"
ret1 = FaxConnectFaxServerA(Environ("computername"), FaxHandle)
'Debug.Print ret1
params.SizeOfStruct = 0 'dont know how to get it.
params.RecipientNumber = "01246456652"
params.RecipientName = "recipient"
params.Tsid = "01246456652"
params.SenderName = "Work"
params.SenderCompany = "CPS"
params.BillingCode = "0"
params.ScheduleAction = JSA_NOW
params.ScheduleTime = stime1
params.DeliveryReportType = DRT_NONE
params.DeliveryReportAddress = "None"
ret1 = FaxSendDocumentA(FaxHandle, filename, params, vbNull, faxjobid)
errno = Err.LastDllError
Debug.Print errno
'Debug.Print ret1
ret1 = FaxClose(FaxHandle)
'Debug.Print ret1
End Sub
Private Sub Form_Load()
params.CallHandle = vbNull
For a = 0 To 3
params.Reserved(a) = &H0
Next
stime1.wYear = 4
stime1.wMonth = 10
stime1.wDayOfWeek = 3
stime1.wDay = 19
stime1.wHour = 17
stime1.wMinute = 30
stime1.wSecond = 10
stime1.wMilliseconds = 1
End Sub
However when i run it i get the error code 87 which means
ERROR_INVALID_PARAMETER i think. The problem im having mainly is that the user defined type fax_job_param is incorrect as i dont know how to go about defining the sizeof the type. Everything else as far as i know is correct.
any help regarding this will be most appreciated thanks.
P.S. this is all the code except the form itself which only has one command button.
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type FAX_JOB_PARAM
SizeOfStruct As Long 'structure size, in bytes
RecipientNumber As String 'pointer to recipient's fax number
RecipientName As String 'pointer to recipient's name
Tsid As String 'pointer to transmitting station identifier
SenderName As String 'pointer to sender's name
SenderCompany As String 'pointer to sender's company
SenderDept As String 'pointer to sender's department
BillingCode As String 'pointer to billing code
ScheduleAction As Long 'job scheduling action code
ScheduleTime As SYSTEMTIME 'time to send fax
DeliveryReportType As Long 'e-mail delivery report type
DeliveryReportAddress As String 'pointer to e-mail address
DocumentName As String 'pointer to document name to display
CallHandle As Long 'reserved
Reserved(3) As Long 'must be zero
End Type
Const JSA_NOW = 0 'Send now Send the fax as soon as a device is available.
Const JSA_SPECIFIC_TIME = 1 'Send at specific time 'Send the fax at the time specified by the ScheduleTime member.
Const JSA_DISCOUNT_PERIOD = 2 'Send at server configured discount period 'Send the fax during the discount rate period. Call the FaxGetConfiguration function to retrieve the discount period for the fax server.
Const DRT_NONE = &H0 '// Do not send DR or NDR receipt to the sender of the fax transmission.
Const DRT_EMAIL = &H1 '// Send DR or NDR receipt by email
Const DRT_INBOX = &H2 '// send DR or NDR receipt to the sender's local personal folder store (PST).
Private Declare Function FaxConnectFaxServerA Lib "winfax.dll" ( _
ByVal MachineName As String, _
ByRef FaxHandle As Long) As Long
Private Declare Function FaxClose Lib "winfax.dll" ( _
ByVal FaxHandle As Long) As Long
Private Declare Function FaxSendDocumentA Lib "winfax.dll" ( _
ByVal FaxHandle As Long, _
ByVal filename As String, _
ByRef jobparams As FAX_JOB_PARAM, _
ByRef CoverpageInfo As Long, _
ByRef faxjobid As Long) As Long
Dim params As FAX_JOB_PARAM
Dim stime1 As SYSTEMTIME
Dim filename As String
Private Sub Command1_Click()
Dim FaxHandle As Long
Dim faxjobid As Long
filename = "c:\currfax.tif"
ret1 = FaxConnectFaxServerA(Environ("computername"), FaxHandle)
'Debug.Print ret1
params.SizeOfStruct = 0 'dont know how to get it.
params.RecipientNumber = "01246456652"
params.RecipientName = "recipient"
params.Tsid = "01246456652"
params.SenderName = "Work"
params.SenderCompany = "CPS"
params.BillingCode = "0"
params.ScheduleAction = JSA_NOW
params.ScheduleTime = stime1
params.DeliveryReportType = DRT_NONE
params.DeliveryReportAddress = "None"
ret1 = FaxSendDocumentA(FaxHandle, filename, params, vbNull, faxjobid)
errno = Err.LastDllError
Debug.Print errno
'Debug.Print ret1
ret1 = FaxClose(FaxHandle)
'Debug.Print ret1
End Sub
Private Sub Form_Load()
params.CallHandle = vbNull
For a = 0 To 3
params.Reserved(a) = &H0
Next
stime1.wYear = 4
stime1.wMonth = 10
stime1.wDayOfWeek = 3
stime1.wDay = 19
stime1.wHour = 17
stime1.wMinute = 30
stime1.wSecond = 10
stime1.wMilliseconds = 1
End Sub