VB.NET: Cancel Delivery Of A Letter with CancelDelivery()
Instructions
- Create a new Console Application project and add a web reference.
- Copy the entire code below, delete anything written in your application and paste the code there.
- Replace the values of the Const lines with your details:
- Replace MyUsername and MyPassword with your PostalMethods user details.
- Replace "ID" with the LetterID for which you would like to cancel.
- Start your application. If the response is -3000, you will see the status report. If the response is any other number, check the Web Service Status Codes section.
Imports System.IO Module Module1 Sub Main() Const MyUsername As String = "MyUsername" Const MyPassword As String = "MyPassword" Const ID As Integer = 0 Dim objPM As New com.postalmethods.api.PostalWSSimple() Dim lngResult As Long ' ' Invoke the CancelDelivery method ' lngResult = objPM.CancelDelivery(MyUsername, MyPassword, ID) ' ' Check response status ' If lngResult = -3000 Then ' ' -3000 means the request was successfully marked for cancellation. ' Console.WriteLine("Request has been cancelled") Else ' ' A value less than -3000 means an error occurred. ' See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes. ' Console.WriteLine("Error is:" & lngResult) End If ' In debug mode, the following lines prevent your console application from closing automatically upon termination Console.WriteLine("Hit ENTER to terminate application") Console.ReadLine() End Sub End Module
