I am trying to get x-mailer header using java mail api.
but my code is not working fine .
What's wrong in my code ?
Java Code:
import com.sun.mail.imap.IMAPFolder;
    import com.sun.mail.imap.IMAPMessage;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.lang.reflect.Field;


/**
 *
 * @author vivek
 */
public class Main {

    public static void main(String[] args) {

    Properties props = System.getProperties();    
    props.setProperty("mail.imap.socketFactory.port", "993");
    props.setProperty("mail.store.protocol", "imaps");
    try {
      Session session = Session.getDefaultInstance(props, null);
      Store store = session.getStore("imaps");
      store.connect("imap.gmail.com", "username", "password");
      System.out.println(store);
      Folder inbox =  store.getFolder("Inbox");
      inbox.open(Folder.READ_ONLY);      
      FetchProfile fp = new FetchProfile();     
      fp.add("X-Mailer"");
      Message[] messages=inbox.getMessages(1, 2);      
      inbox.fetch(messages, fp);            
      for (Message message : messages) {
        System.out.println(message);        
        System.out.println(message.getHeader("X-Mailer""));

      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }

  }
}