C#: Cancel Delivery Of A Letter with CancelDelivery()

Instructions

  1. Create a new Console Application project and add a web reference.
  2. Copy the entire code below, delete anything written in your application and paste the code there.
  3. Replace the values of the Const lines with your details:
    • Replace MyUsername and MyPassword with your PostalMethods user details.
    • Replace “ID” with the ID of the letter or postcard you would like to cancel.
  4. 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.
using System;
 
namespace ConsoleApplication1
{
    class CancelDelivery
    {
 
        public static void Main()
        {
            const string MyUsername = "MyUsername";
            const string MyPassword = "MyPassword";
            const int ID = 0;
 
            com.postalmethods.api.PostalWS objPM = new com.postalmethods.api.PostalWS();
            long lngResult = 0;
 
            //
            // Invoke the GetLetterStatus_Multiple method
            //
            lngResult = objPM.CancelDelivery(MyUsername, MyPassword, ID);
 
            //
            // Check response status
            //
            if (lngResult == -3000)
            {
                //
                // -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);
            }
 
            // In debug mode, the following lines prevent your console application from closing automatically upon termination
            Console.WriteLine("Hit ENTER to terminate application");
            Console.ReadLine();
 
        }
    }
 
}
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!