VB.NET: Delete an uploaded file using DeleteUploadedFile()

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 MyFileName with the name of the file, including its extension, as it was given when uploaded.
  4. Start your application. If the response is -3000, the file was deleted. 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 MyFileName As String = "PurchaseInvoice.mht"
 
        Dim objPM As New com.postalmethods.api.PostalWS()
        Dim lngResult As Long
 
        ' Invoke the DeleteUploadedFile method
        lngResult = objPM.DeleteUploadedFile( _
                                MyUsername, _
                                MyPassword, _
                                MyFileName)
 
        ' 
        ' Check response status
        '
        If lngResult = -3000 Then
            '
            ' If the result code = -3000, the file was deleted.
            '
            Console.WriteLine("File deleted!")
        Else
            '
            ' A negative value means an error occurred.
            ' See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes#webservice.
            '
            Console.WriteLine("An error occurred:" & 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
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!