0

我创建了一个想在网络浏览器上运行的小程序。该小程序包含发送电子邮件和使用 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 );
    }

你能告诉我什么许可,我应该在哪里提供?谢谢

4

1 回答 1

0

如果要在另一个选项卡或窗口中打开新页面,请尝试以下操作:

getAppletContext().showDocument(url.toURI(), "_blank");

“_self”在包含小程序的窗口和框架中显示。
"_parent"在小程序的父框架中显示。如果没有父框架,则与“_self”作用相同。
"_top" 显示在小程序窗口的顶层框架中。如果小程序的框架是顶级框架,则与“_self”作用相同。
"_blank" 在一个新的、未命名的顶级窗口中显示。

于 2012-05-23T17:09:12.193 回答