C#: Get Letter Metadata with GetLetterDetailsV2()

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 LetterID for which you would like to get the metadata.
  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 GetLetterDetailsV2
    {
 
        public static void Main()
        {
            const string MyUsername = "MyUsername";
            const string MyPassword = "MyPassword";
            const int ID = 0;
 
            com.postalmethods.api.PostalWSSimple objPM = new com.postalmethods.api.PostalWSSimple();
            com.postalmethods.api.GetLetterDetailsV2Result objResult = default(com.postalmethods.api.GetLetterDetailsV2Result);
 
            //
            // Invoke the GetLetterStatus_Multiple method
            //
            objResult = objPM.GetLetterDetailsV2(MyUsername, MyPassword, ID);
 
            //
            // Check response status
            //
            if (objResult.ResultCode == -3000)
            {
                //
                // -3000 means that the data was successfully retrieved.
                //
                Console.WriteLine("ID: {0}", objResult.ID);
                Console.WriteLine("Work mode: {0}", objResult.WorkMode.ToString());
                Console.WriteLine("Submit Time: {0}", objResult.SubmitTime);
                Console.WriteLine("Completion Time: {0}", objResult.CompletionTime);
                Console.WriteLine("Envelope: {0}", objResult.Envelope);
                Console.WriteLine("International Mailing: {0}", objResult.InternationalMailing);
                Console.WriteLine("National Mailing: {0}", objResult.NationalMailing);
                Console.WriteLine("Number of sheets: {0}", objResult.NumOfSheets);
                Console.WriteLine("Orientation: {0}", objResult.Orientation);
                Console.WriteLine("Paper: {0}", objResult.Paper);
                Console.WriteLine("Price: {0}", objResult.Price);
                Console.WriteLine("Print Color: {0}", objResult.PrintColor);
                Console.WriteLine("Print Sides: {0}", objResult.PrintSides);
            }
            else
            {
                //
                // A value less than -3000 means an error occurred.
                // See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes.
                //
                Console.WriteLine("Error is:" + objResult.ResultCode);
            }
 
            // In debug mode, the following lines prevent your console application from closing automatically upon termination
            Console.WriteLine("Hit ENTER to terminate application");
            Console.ReadLine();
 
        }
    }
 
}