![]() |
|
|
| Welcome | User Tools | Developer Tools | Prices | Help | Sign up | Login |
| Overview | Web Service | Email Interface | COM Object | Forum | Developer Registration |
| You are here:
Home > Developer Tools > Fax Web Service > Samples > ASP - Faxing Text of any Character Set |
||
Fax Web Service Code SampleASP - Faxing Text of any Character Set (Sendfax or SendfaxEx_2 Methods)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 2. 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") = TrueOption 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" |
||
| About | Contact | Privacy | Terms | Partners | Login | System Status © Interfax Inc |