Java: Send A Letter With SendLetter()

Download Download Java samples [.zip]. Find this sample in directory /test/com/postalmethods/client

This sample demonstrates how to send a letter through PostalMethods using the Address Inside method.

package com.postalmethods.client;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import com.postalmethods.client.api.SendLetterResponse;
public class SendLetterTest {
    private PostalMethodsClient client;
    public void setUp() {
        //client = new PostalMethodsClientFactory().build(TestConstants.USERNAME, TestConstants.PASSWORD);
        client = new PostalMethodsClientFactory().build();
    public void testSendLetter() {
        System.out.println("Making call to SendLetter...");
        SendLetterResponse response = client.sendLetter("Sending test letter via JUnit integration test.", TestConstants.SAMPLE_LETTER_FILENAME);
        System.out.println("Service call completed:\n" + response.getResult().toString());
        int code = response.getResult().getCode();
        assertTrue(code > 0 );
        System.out.println("New letter id is: " + code);