为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

不难,请看javamail 发送附件的例子

2017-10-07 3页 doc 14KB 15阅读

用户头像

is_882336

暂无简介

举报
不难,请看javamail 发送附件的例子不难,请看javamail 发送附件的例子 作者:jeru email: jeru@163.net 日期:2001-1-9 18:37:32 Here is the code to send an attachment: import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class AttachExample { public st...
不难,请看javamail 发送附件的例子
不难,请看javamail 发送附件的例子 作者:jeru email: jeru@163.net 日期:2001-1-9 18:37:32 Here is the code to send an attachment: import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class AttachExample { public static void main (String args[]) throws Exception { String host = args[0]; String from = args[1]; String to = args[2]; String fileAttachment = args[3]; // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", host); // Get session Session session = Session.getInstance(props, null); // Define message MimeMessage message = new MimeMessage(session); message.setFrom( new InternetAddress(from)); message.addRecipient( Message.RecipientType.TO, new InternetAddress(to)); message.setSubject( "Hello JavaMail Attachment"); // create the message part MimeBodyPart messageBodyPart = new MimeBodyPart(); //fill message messageBodyPart.setText("Hi"); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); // Part two is attachment messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(fileAttachment); messageBodyPart.setDataHandler( new DataHandler(source)); messageBodyPart.setFileName(fileAttachment); multipart.addBodyPart(messageBodyPart); // Put parts in message message.setContent(multipart); // Send the message Transport.send( message ); } } Made by an Unregistered version of eTextWizard V 1.95
/
本文档为【不难,请看javamail 发送附件的例子】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索