ASP: Cancel Delivery Of A Letter with CancelDelivery()

Instructions

  1. Create a new ASP page.
  2. Copy the entire code below and paste the code there.
  3. Replace MyUsername and MyPassword with your PostalMethods user details.
  4. Replace ID with the LetterID you would like to cancel.
  5. 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. 
'
Option Explicit 
 
Const MyUsername = "MyUsername"
Const MyPassword = "MyPassword"
' Replace with the LetterID of the Letter, as returned by the sending method, such as SendLetter()
Const LetterID="ID" 
 
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.
'
objSoap.mssoapinit("http://api.postalmethods.com/2009-02-26/PostalWS.asmx?WSDL")
'
'Set to True when a proxy server is to be detected automatically
'
objSoap.ConnectorProperty("EnableAutoProxy") = True
'
' Invoke the SendLetter method
'
lngResult = objSoap.CancelDelivery( _
				MyUsername, _
				MyPassword, _
				LetterID)
 
If CLng(lngResult) = -3000 Then 
	'
	' -3000 means the request was successfully marked for cancellation.
	'
	Response.Write "Letter was requested to be canceled"
Else 
	'
	' A value less than -3000 means an error occurred.
	' See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes.
	'
    Response.Write "Error is:" & lngResult
End If
 
%>

Go back to:‹ ASP: Send A Letter with SendLetterAndAddress()
Send Letters
Securely + Reliably
Send letters securely and reliably from any business application. Use for invoices, quotes, and other important business communications. Enjoy special web-form to postal features and instant notifications.
Simple Process
Easy as 1-2-3
Experience the ease of our streamlined process - developed for efficiency! You submit your document by email or API. We automatically print, collate, insert, and stamp your letter. Your letter is delivered via standard postal service.
Pay As You Go
No Fuss. No Obligations.
Register for free with no obligations! Evaluate the service as long as you need. Once you are ready, set up our user-friendly pay-as-you option to use our service. No fuss. No on-going commitment. Just plain easy!