Web ブラウザで実行するアプレットを作成しました。アプレットには、電子メールの送信や、URI を使用した別のアプレットを開くなどの機能が含まれています。
インターフェイスは正常に動作します。でも、
これらの部分は許可が必要なようです。
...........................................................
//creating session
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
// to add recipients
InternetAddress[] toAddress = new InternetAddress[to.size()];
// To get the array of recipients addresses
for( int i=0; i < to.size(); i++ ) {
toAddress[i] = new InternetAddress(to.get(i));
}
System.out.println(Message.RecipientType.TO);
//adding recipients
for( int i=0; i < toAddress.length; i++) {
message.addRecipient(Message.RecipientType.TO, toAddress[i]);
}
message.setSubject(subject);
message.setText("This is Zaid's app");
// check if animation was selected
if(animation)
fileName= attachment +".gif";
else
fileName = attachment +".JPEG";
//add the attachment
MimeBodyPart attachMent = new MimeBodyPart();
FileDataSource dataSource= new FileDataSource(new File("ScaryImages//"+ fileName));
attachMent.setDataHandler(new DataHandler(dataSource));
attachMent.setFileName(fileName);
attachMent.setDisposition(MimeBodyPart.ATTACHMENT);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(attachMent);
message.setContent(multipart);
//this is the sender variable
Transport transport = session.getTransport("smtp");
//trying to send...
try{
System.out.println("connecting...");
transport.connect(host, from, pass);
System.out.println("sending...Please wait...");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("sent");
JOptionPane.showMessageDialog(null,"Your Email has been sent successfully!");
}
catch(Exception e)
{
//exception handling, the problem is mainly the connection
JOptionPane.showMessageDialog(null,"Connection Problem has been detected! Please Try again.");
e.printStackTrace(System.out);
}
//remove loading label anyway
finally{
EmailApplet.removeLoadingLabel();
}
.......................
これも、
試す {
java.net.URI uri = new java.net.URI( arg );
desktop.browse( uri );
}
どのような許可をどこで提供すればよいか教えてください。ありがとうございました