Question

I am having trouble with the FaxDoc.Bodies function. I get the error "Methods data should be passed in a one-dimensional zero-based array of strings."

I have tried everything I can think of, from using array() directly on the FaxDoc.Bodies element. Any ideas?

Dim strJobIds
Dim STAttach(1)
'On Error Resume Next 
Set FaxServer = WScript.CreateObject("FAXCOMEX.FaxServer") 

WScript.Echo "FaxServer created"  
FaxServer.Connect "" 


Set FaxDoc = WScript.CreateObject("FAXCOMEX.FaxDocument") 



STAttach(0)="chili.txt"
STAttach(1)="sugarcookies.txt"


FaxDoc.Bodies=STAttach

FaxDoc.DocumentName = "My First Fax" 

FaxDoc.Recipients.Add ("15555551234") 

FaxDoc.Sender.Email = "bob@xyz.com" 
FaxDoc.Sender.Name = "Bob" 
FaxDoc.Sender.FaxNumber = "15555555678"

'    Optionally, Use FaxDoc.CoverPage and FaxDoc.CoverPageType to specify a cover page 
'    FaxDoc.CoverPage = generic 
'    FaxDoc.CoverPageType = 2 

'    Optionally, you can control banner in outbound faxes 
FaxServer.Folders.OutgoingQueue.Branding = True
FaxServer.Folders.OutgoingQueue.Save     '      Make the change persistent 
'    Optionally, use FaxServer.Folders.OutgoingQueue.Retries and 
'    FaxServer.Folders.OutgoingQueue.RetryDelay to control retries 

'    Submit the document to the connected fax server and get back the job ID. 
strJobIds=""
JobID = FaxDoc.ConnectedSubmit2(FaxServer, strJobIds) 

WScript.Echo "FaxDoc.ConnectedSubmit success"
Was it helpful?

Solution

It asks for an array and using the semicolon separator does not work and returns the same error messages.

I did, however, find a solution using a VBA Console Application instead of VBScript. My code is as follows:

Module Module1
    Function DecodeToDocArray(ByVal inputDocListString As String, ByRef numDocuments As Integer, ByRef bRetVal As Boolean) As String()
        bRetVal = False
        If (String.IsNullOrEmpty(inputDocListString)) Then
            Return Nothing
        End If
        Dim docArray As String()
        Dim strDelimiter As String
        Dim delimiter As Char()

        docArray = Nothing
        strDelimiter = ";"
        delimiter = strDelimiter.ToCharArray()
        docArray = inputDocListString.Split(delimiter)
        numDocuments = docArray.GetLength(0)
        bRetVal = True
        Return docArray
    End Function
    Sub Main()



        Dim retVal As Boolean
        Dim numDocs As Integer
        Dim docArray As String()
        Dim strDocList As String = "chili.txt;sugarcookies.txt"
        MsgBox(strDocList)
        numDocs = 0
        docArray = DecodeToDocArray(strDocList, numDocs, retVal)
        If ((docArray.GetLength(0) = 0) Or (retVal = False)) Then
            System.Console.WriteLine("DecodeToDocArray failed")
            retVal = False
            MsgBox("End")
            End
        End If

        Dim FaxDoc = CreateObject("FAXCOMEX.FaxDocument")
        Dim FaxServer = CreateObject("FAXCOMEX.FaxServer")
        FaxServer.Connect("")

        MsgBox("test")
        FaxDoc.Bodies = docArray
        FaxDoc.Sender.LoadDefaultSender()
        FaxDoc.Recipients.Add("15555551234", "TestUser")
        Dim strJobIds As Object
        strJobIds = Nothing

        FaxDoc.ConnectedSubmit2(FaxServer, strJobIds)

        MsgBox("sent")

    End Sub

End Module

OTHER TIPS

According to MSDN you should pass the documents as a string with the documents separated by a semi colon:

FaxDoc.Bodies = "chili.txt;sugarcookies.txt"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top