我创建了一个想在网络浏览器上运行的小程序。该小程序包含发送电子邮件和使用 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 );
}
你能告诉我什么许可,我应该在哪里提供?谢谢