C#: Get Letter And Postcard Delivery Details with GetDetailsExtended()

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 “MyUsername” and “MyPassword” with your PostalMethods user details
  4. Replace “IDs” with a single ID of one of your sent mail items, multiple IDs (ID1,ID2,ID3) or a range of IDs (ID1-ID2)
  5. Start your application. If the response is -3000, you will see the details report. If the response is any other number, check the Web Service Status Codes section.
using System;
 
namespace ConsoleApplication1
{
    class GetDetailsExtended
    {
 
        public static void Main()
        {
            const string MyUsername = "MyUsername";
            const string MyPassword = "MyPassword";
            const string IDs = "0";       // To query a single mail item
            //const string IDs = "0,0,0"; // To query multiple mail items
            //const string IDs = "0-0";   // To query a range of mail items
 
 
            com.postalmethods.api.PostalWS objPM = new com.postalmethods.api.PostalWS();
            com.postalmethods.api.GetDetailsExtendedResult objResult = default(com.postalmethods.api.GetDetailsExtendedResult);
 
            //
            // Invoke the GetDetailsExtended method
            // 
 
 
            objResult = objPM.GetDetailsExtended(MyUsername, MyPassword, IDs);
 
            //
            // Check response status
            //
            if (objResult.ResultCode == -3000)
            {
                //
                // -3000 means that the statuses were successfully retrieved.
                // Write them down.
                //
                Console.WriteLine("Successfully retrieved results");
                foreach (com.postalmethods.api.ExtendedDetails Details in objResult.Details)
                {
                    WriteDetails(Details);
                }
            }
            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("**********************************");
            Console.WriteLine("Hit ENTER to terminate application");
            Console.ReadLine();
 
        }
 
        private static void WriteDetails(com.postalmethods.api.ExtendedDetails Details)
        {
            Console.WriteLine("**********************************");
            Console.WriteLine("ID: " + Details.ID);
            Console.WriteLine("Status: " + Details.Status);
            Console.WriteLine("Status Description: " + Details.StatusDescription);
            Console.WriteLine("Completion Time: " + Details.CompletionTime);
            Console.WriteLine("Is Batch: " + Details.IsBatch);
            Console.WriteLine("Mailer Type: " + Details.MailerType);
            Console.WriteLine("MyDescription: " + Details.MyDescription);
            Console.WriteLine("Num Of Sheets: " + Details.NumOfSheets);
            Console.WriteLine("Price: " + Details.Price);
            Console.WriteLine("SubmitTime: " + Details.SubmitTime);
            Console.WriteLine("Work Mode: " + Details.WorkMode);
            Console.WriteLine("Print Color: " + Details.PrintColor);
            Console.WriteLine("Print Sides: " + Details.PrintSides);
            Console.WriteLine("Postcard: " + Details.Postcard);
            Console.WriteLine("Envelope: " + Details.Envelope);
            Console.WriteLine("Orientation: " + Details.Orientation);
            Console.WriteLine("Paper: " + Details.Paper); 
            Console.WriteLine("International Mailing: " + Details.InternationalMailing);
            Console.WriteLine("National Mailing: " + Details.NationalMailing);
        }
 
    }
}
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!