Faxing Text of any Character Set

25 Nov 2016 This code sample is deprecated and in process of being removed. Check out our new code libraries and usage documentation on InterFAX @ Github.

ASP project files for faxing text of any character set.

Download the ASP project files.

Note:
1. If you only need to fax ASCII text (i.e., no special character set), you can use the simpler sample describing how to Send a Textual Fax

  1. Please read the note in the sample file, which describes a workaround to a limitation in Microsoft's Visual Basic Scripting Edition.
<%
'
' This asp script demonstrates how to send a text from
' an ASP script, using MS SOAP 3.0 and the SendfaxEx_2
' method within Interfax (Sendfax is commented out, but
' can be used as well). These methods require data to be
' passed as a byte array. As ASP has no provisions for
' converting text to binary, we use ADODB.Stream object to do so.
'

Option Explicit

Const StringToFax = "Hello world from text."

Dim objSoap, SendfaxResult
Dim B
'
'Convert string into a byte-array
'
B = Stream_StringToBinary(StringToFax,"us-ascii")
'
'Create the SoapClient object    'MS SOAP v3.0
'
Set objSoap = Server.CreateObject("MSSOAP.SOAPClient30")
'
'Set to True when an Active Server Pages (ASP) application or an ISAPI DLL uses the SoapClient object.
'
objSoap.ClientProperty("ServerHTTPRequest") = True
'
'Initializes the SoapClient object with the dfs.wsdl file
'
objSoap.mssoapinit("http://ws.interfax.net/dfs.asmx?WSDL")
'
'Set to True when a proxy server is to be detected automatically
'
objSoap.ConnectorProperty("EnableAutoProxy") = True
'
' Invoke the Interfax method
'
'SendfaxResult = objSoap.Sendfax("username", "password", "5480015", B , "txt")
SendfaxResult = objSoap.SendfaxEx_2("username", "password", "5480015", "", B, _
"txt", UBOUND(B)+1, Now, 3, "MyCSID", "", "", "Fax Subject", "myaddress@mydomain.com", _
"Letter", "Landscape", False, True)


'SendfaxResult = objSoap.Sendfax("your user name", "your password", "+44965157785", base64_Text, "html")

If CLng(SendfaxResult) > 0 Then
    Response.Write "Fax submitted. Transaction ID: " & SendfaxResult
Else
    Response.Write "Error sending fax. Return code: " & SendfaxResult
End If

'*********************************************************

Function Stream_StringToBinary(Text, CharSet)
  Const adTypeText = 2
  Const adTypeBinary = 1
 
  'Create Stream object
  Dim BinaryStream 'As New Stream
  Set BinaryStream = CreateObject("ADODB.Stream")
 
  'Specify stream type - we want To save text/string data.
  BinaryStream.Type = adTypeText
 
  'Specify charset For the source text (unicode) data.
  If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
  Else
    BinaryStream.CharSet = "us-ascii"
  End If
 
  'Open the stream And write text/string data To the object
  BinaryStream.Open
  BinaryStream.WriteText Text
 
  'Change stream type To binary
  BinaryStream.Position = 0
  BinaryStream.Type = adTypeBinary
 
  'Open the stream And get binary data from the object
  Stream_StringToBinary = BinaryStream.Read

  'Clean up
  BinaryStream.Close
  Set BinaryStream = Nothing

End Function

%> 

'Note: If you are faxing from behind a proxy using MS SOAP v.3, you can use one of the two following options:

'Option 1 - Use automatic detection by:
     objSoap.ConnectorProperty("EnableAutoProxy") = True

'Option 2 - Specify a proxy server:
     objSoap.ConnectorProperty("ProxyServer") = "192.168.0.100"
'and optionally, if the proxy server is password-protected specify:
     objSoap.ConnectorProperty("ProxyUser") = "Proxy Username"
     objSoap.ConnectorProperty("ProxyPassword") = "Proxy Password"

Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today