当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 本文根据Ian F. Darwin的《Java Cookbook》整理而成,原书用整章的文字介绍如何发邮件,可能头绪会比较乱,本文则将其浓缩成一篇文章,力求使完全不懂JavaMail的人,都可以根据文中指示稍作修改,拿来就可以用。
 

 

 ·java新功能之一枚举     »显示摘要«
    摘要: java中的枚举 作者:wfg package a001;// 最新在学习java 新功能中枚举//就写了如下这样的一个例子/*public enum testenum{ red("color-ff0000") { void setinfo(string val) { strinfo=val; } string getinfo() { return strinfo; } }......
 ·基于目录结构认证的问题     »显示摘要«
    摘要: 目录结构以tree形式展现,按照rbac的规范,我把目录当做一种资源(resource),然后以permission=resource+operation来定义权限,operation包括view,edit,check in/out等, 定义一个权限的大概流程是:在目录树上选择某一目录节点,然后选择一种操作类型,由此定义一个对该节点的权限permission1。 按此方式授权:permissio......


用JavaMail发送带附件的邮件

本文根据ian f. darwin的«java cookbook»整理而成,原书用整章的文字介绍如何发邮件,可能头绪会比较乱,本文则将其浓缩成一篇文章,力求使完全不懂javamail的人,都可以根据文中指示稍作修改,拿来就可以用.如果对其中原理还有不清楚,你可以参考原书.

1.mailconstants.java,properties文件的助记符:///////////////////////////////////////////////////////////////////////package untitled2; 【程序编程相关:工作流中间件与应用系统结合方式分析

一.首先要用到三个java文件: 【推荐阅读:eclipse+tomcat+lombo

  public static final string send_proto = "mail.send.protocol";  public static final string send_user = "mail.send.user";  public static final string send_pass = "mail.send.password";  public static final string send_root = "mail.send.root";  public static final string send_host = "mail.send.host";  public static final string send_debug = "mail.send.debug"; 【扩展信息:IIS和tomcat5多站点配置

/** simply a list of names for the mail system to use. * if you "implement" this interface, you dont have to prefix * all the names with mailprops in your code. */public interface mailconstants {  public static final string props_file_name = "mailclient.properties";

  public static final string recv_proto = "mail.receive.protocol";  public static final string recv_port = "mail.receive.port";  public static final string recv_user = "mail.receive.user";  public static final string recv_pass = "mail.receive.password";  public static final string recv_root = "mail.receive.root";  public static final string recv_host = "mail.receive.host";  public static final string recv_debug = "mail.receive.debug";}///////////////////////////////////////////////////////////////////////

2.fileproperties.java,从文件中读取properties:///////////////////////////////////////////////////////////////////////package untitled2;

import java.io.*;import java.util.*;

/** * the <code>fileproperties</code> class extends <code>properties</code>, * "a persistent set of properties [that] can be saved to a stream * or loaded from a stream". this subclass attends to all the mundane * details of opening the stream(s) for actually saving and loading * the properties. * * <p>this subclass preserves the useful feature that * a property list can contain another property list as its * "defaults"; this second property list is searched if * the property key is not found in the original property list. * * @author ian f. darwin, ian@darwinsys.com * @version $id: fileproperties.java,v 1.5 2001/04/28 13:22:37 ian exp $ */public class fileproperties    extends properties {  protected string filename = null;


...   下一页
 ·javamail的几个实用知识点.     »显示摘要«
    摘要:1.把邮件保存为一个文件,这个文件可以直接用outlook,foxmail等邮件客户端工具打开。 private void savemail(mimemessage msg, string path) { try { file f = new file(path); f.getparentfile().mkdirs(); fileoutputstream fo = new fileoutputst......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE