Search code examples
javaemailimap

how to use getInReplyTo()?


I am trying to get information about the mail to which a particular mail has replied... I am using getInReplyTo() function of imap but I don't know how to use it as I am begginer.... This is my code:

 MimeMessage msg = (MimeMessage) messages[i];
String replyto = msg.getInReplyTo();
          System.out.println(replyto);

but it gives error:

test2.java:129: error: cannot find symbol
           String replyto = msg.getInReplyTo();
                               ^


 symbol:   method getInReplyTo()
  location: variable msg of type MimeMessage

What am i doing wrong??


Solution

  • To explain about the error, it says there there is no method getInReplyTo() available in MimeMessage Class definition. To solve your problem, You are using MimeMessage type instead of IMAPMessage type. Change the type of msg variable to type IMAPMessage.

    Note : You are doing the typecase to MimeMessage and then invoking the IMAPMessage 's method. You can't do that.