是用java语言调用(vb,vc,delphi的例子网上有很多了)
    实现的效果就像在ie地址栏输入mailto:***@sss.com一样,windows会自动启动默认的邮件客户端(比如OE,foxmail,Lotus Notes等)新建一封邮件,***@sss.com会作为收件人,然后用户点击send就可以发出去了.
    我这个应用不能直接用java调mailto,因为mailto不支持添加附件.也不能用那种需要smtp server参数和用户密码的程序来发送,因为那种程序(比如很多javamail的代码)都是自动发送邮件了.我需要的是会出现邮件客户端的界面,然后需要用户点击send按钮才发送邮件的程序.
    我目前想到了两种方法,哪位大侠提供其中一种方法的源码都可以给分结贴:
  1.用JNI调mapi.
  网上有很多vc,vb的实现都是调用mapi实现的,但是java要调用系统级的api比较麻烦,我所知道的就只有jni了.我对jni也不太懂.如果有高手可以根据网上已有的c++调用邮件客户端的代码,写出jni调用这段代码的java代码,我想这个问题就解决了
  2.调用邮件客户端的api
 我现在电脑上用的是lotus notes,我做的这个软件产品的客户也是用lotus notes作为缺省的邮件客户端.所以如果有人可以用louts notes的api(我大概知道有个notes.jar)来实现也是可以的

解决方案 »

  1.   

    下面是一段用Java mail API发带附件邮件的方法,附件是读的硬盘上的文件,你参考下吧        
    String message="Mail send OK!";   
            Session session=null;   
            Properties props = System.getProperties();   
            props.put("mail.smtp.host", smtpServer);   
            if(ifAuth){ //the mail server ask auth   
                props.put("mail.smtp.auth","true");      
                MailAuth smtpAuth=new MailAuth(username,password);   
                session=Session.getDefaultInstance(props, smtpAuth);    
            }else{   
                props.put("mail.smtp.auth","false");   
                session=Session.getDefaultInstance(props, null);   
            }   
            session.setDebug(isDebug);           Transport trans = null;
            try {   
                Message msg = new MimeMessage(session);    
                try{   
                 Address from_address;
                 if (displayName == null)
                 from_address = new InternetAddress(from);
                 else 
                 from_address = new InternetAddress(from, displayName);
                    msg.setFrom(from_address);   
                }catch(java.io.UnsupportedEncodingException e){   
                    e.printStackTrace();   
                }   
                //InternetAddress[] address={new InternetAddress(to)};   
                InternetAddress[] address= InternetAddress.parse(to);   
                msg.setRecipients(Message.RecipientType.TO,address);   
                msg.setSubject(subject);   
                
                if (cc != null) {
                    InternetAddress[] ccAddr= InternetAddress.parse(cc);   
                 msg.setRecipients(Message.RecipientType.CC, ccAddr);
                }
                
                
                Multipart mp = new MimeMultipart();   
                MimeBodyPart mbp = new MimeBodyPart();   
                //mbp.setContent(content.toString(), "text/html"); //;charset=gb2312");   
                mbp.setContent(content.toString(), "text/plain"); //;charset=gb2312");   
                mp.addBodyPart(mbp);     
                if(!file.isEmpty()){//have attachment
                    Enumeration efile=file.elements();   
                    while(efile.hasMoreElements()){    
                        mbp=new MimeBodyPart();   
                        filename=efile.nextElement().toString(); //get each attachment name   
                        FileDataSource fds=new FileDataSource(filename); //get the file data source
                        mbp.setDataHandler(new DataHandler(fds)); //get the attachment content  
                        mbp.setFileName(fds.getName());  //get the file name and include to content
                        mp.addBodyPart(mbp);   
                    }     
                    file.removeAllElements();       
                }    
                msg.setContent(mp); // add the Multipart into mail    
                msg.setSentDate(new Date());     //set the date in mail header               // send   
                msg.saveChanges();    
                trans = session.getTransport("smtp");   
                trans.connect(smtpServer, username, password);   
                trans.sendMessage(msg, msg.getAllRecipients());   
                trans.close();   
                  
            }catch(AuthenticationFailedException e){      
                 map.put("state", "failed");   
                 message="Mail send fail!Error caused:auth error!\n";   
                 e.printStackTrace();    
            }catch (MessagingException e) {   
                 message="Mail send fail!Error caused:\n"+e.getMessage();   
                 map.put("state", "failed");   
                 e.printStackTrace();   
                 Exception ex = null;   
                 if ((ex = e.getNextException()) != null) {   
                     System.out.println(ex.toString());   
                     ex.printStackTrace();   
                 }    
            }   
      

  2.   

    你这是要调用windows的API了,那只用使用JNI来调用WINDOWS的API了
      

  3.   

    to 6 楼:能不能给一个JNI调用mapi的例子?JNI调用windows的api好像其实是先写好了C/C++调用windows api的程序,然后java再调用这段C/C++程序,不知道我的理解对不对
      

  4.   

    Runtime.getRuntime().exec("explorer.exe mailto:[email protected]");
      

  5.   

    to 8 楼
     这个我以前就试过了,mailto协议是不能加附件的,而且我在原帖里已经说了,由于不能加附件,mailto达不到我的要求.所以对不起,这贴暂时还不能结
      

  6.   

    如果是FOXMAIL,倒是可以:
    Foxmail.exe /min d:\a.txt d:\b.txt
    带上附件
      

  7.   

    是啊,所以才想到调用mapi啊,这一定可以实现的.但是java调用这些系统api真的没用过.我也只会java编程,c++完全不懂啊,所以想请教csdn的高手帮忙