![]() |
|
|
| 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 a File |
||
Fax Web Service Code SampleASP - Faxing a File (Sendfax Method)Download the ASP project files.Note: 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 binary file ' (such as .PDF, .DOC) 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). As asp has no ' provisions to reading binary files, we use an ADODB.Stream ' object to do so. ' Option Explicit Const FilenametoFax = "C:\temp\hw.txt" Dim objSoap, SendFaxResult Dim B ' 'Read data from a file to a byte-array ' B = ReadBinaryFile(FilenametoFax) ' '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 ReadBinaryFile(FileName) Const adTypeBinary = 1 'Create Stream object Dim BinaryStream Set BinaryStream = CreateObject("ADODB.Stream") 'Specify stream type - we want To get binary data. BinaryStream.Type = adTypeBinary 'Open the stream BinaryStream.Open 'Load the file data from disk To stream object BinaryStream.LoadFromFile FileName 'Open the stream And get binary data from the object ReadBinaryFile = 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 |