问题
I am trying to deploy an Oracle MAF app to the iOS platform. I am using Java Mail to receive emails from the gmail server. I am trying to to identify mails that have attachments. However I get the following error.
java.lang.ClassCastException: com.sun.mail.imap.IMAPInputStream cannot be cast to javax.mail.Multipart
When I identify the mime type of the message as "multipart/mixed", I am trying to cast the object into Multipart.
I understand that this question has been asked before but I have tried to implement the solution proposed here. However I am unable to import anything from javax.activation. The error that I get in jdeveloper is
Error : javax.activation.CommandMap is not available in the profile.
This error shows up for everything from javax.activation
Also, this error pops up only in an MAF application. It works well in a normal java project.
How can I handle this issue?
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Store;
public class Email {
public Email()
{
String userName = "abc@gmail.com";
String password = "password";
String receivingHost;
receivingHost="imap.gmail.com";
Properties props=System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session=Session.getDefaultInstance(props, null);
try
{
Store store=session.getStore("imaps");
store.connect(receivingHost,userName, password);
Folder folder=store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message messages[]=folder.getMessages();
//System.out.println(messages.length);
for (Message message : messages)
{
if(message.isMimeType("multipart/mixed"))
{
Multipart mp = (Multipart)message.getContent();
//get content
}
else
{
//getcontent
}
}
store.close();
}
catch (Exception e)
{
System.out.println(e.toString());
}
//System.out.println("Done");
}
}
来源:https://stackoverflow.com/questions/38436576/unable-to-import-javax-activation-in-jdeveloper-for-maf