- Create a new ASP page.
- Copy the entire code below and paste the code there.
- Replace MyUsername and MyPassword with your PostalMethods user details.
- Replace ID with the LetterID you would like to cancel.
- Start your application. If the response is -3000, PostalMethods is trying to cancel your letter. You should query its status. If the response is any other number, check the Web Service Status Codes section.
' This asp script demonstrates how to cancel a delivery of a Letter, using MS SOAP 3.0
' and the CancelDelivery method within PostalMethods.
Const MyUsername = "MyUsername"
Const MyPassword = "MyPassword"
' Replace with the LetterID of the Letter, as returned by the sending method, such as SendLetter()
Dim objSoap, lngResult
'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. ASP initializes the WSDL on each call.
'For better performance, you may download the WSDL locally as an XML and refer to the local file.
'Set to True when a proxy server is to be detected automatically
objSoap.ConnectorProperty("EnableAutoProxy") = True
' Invoke the SendLetter method
lngResult = objSoap.CancelDelivery( _
If CLng(lngResult) = -3000 Then
' -3000 means the request was successfully marked for cancellation.
Response.Write "Letter was requested to be canceled"
' A value less than -3000 means an error occurred.
' See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes.
Response.Write "Error is:" & lngResult