日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java邮箱设置密送_修改后可以发送附件、抄送、密送的javabean,吐血推荐~(javamail范例)...

發(fā)布時(shí)間:2025/3/21 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java邮箱设置密送_修改后可以发送附件、抄送、密送的javabean,吐血推荐~(javamail范例)... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

修改后可以發(fā)送附件、抄送、密送的javabean,吐血推薦~(javamail范例)

作者:Andy.m????文章來源:www.jspcn.net

發(fā)布日期:2004年02月16日

/*

*Author:tyfun

*DateTime:2003.01.09

*Package:com.westarsoft.function

*/

package?com.westarsoft.function;

import?java.util.*;

import?java.io.*;

import?javax.mail.*;

import?javax.mail.internet.*;

import?javax.activation.*;

public?class?SendMail?{

private?String?SMTPServer?=?new?String();

private?String?from?=?new?String();

private?String?subject?=?new?String();

private?String?content?=?new?String();

private?String?user?=?new?String();

private?String?password?=?new?String();

private?String?fileAttachment?=?new?String();

public?String?getSMTPServer()?{

return?SMTPServer;

}

public?void?setSMTPServer(String?SMTPServer)?{

this.SMTPServer?=?SMTPServer;

}

public?String?getFrom()?{

return?from;

}

public?void?setFrom(String?from)?{

this.from?=?from;

}

public?String?getSubject()?{

return?subject;

}

public?void?setSubject(String?subject)?{

this.subject?=?subject;

}

public?String?getContent()?{

return?content;

}

public?void?setContent(String?content)?{

this.content?=?content;

}

public?String?getUser()?{

return?user;

}

public?void?setUser(String?user)?{

this.user?=?user;

}

public?String?getPassword()?{

return?password;

}

public?void?setPassword(String?password)?{

this.password?=?password;

}

public?String?getFileAttachment()?{

return?fileAttachment;

}

public?void?setFileAttachment(String?fileAttachment)?{

this.fileAttachment?=?fileAttachment;

}

public?void?sendMailTo(String?to,String?cc,String?bcc)?{

try?{

Properties?props?=?new?Properties();

Session?sendMailSession;

Store?store;

Transport?transport;

sendMailSession?=?Session.getInstance(props,?null);

props.put("mail.smtp.host",?SMTPServer);

MimeMessage?newMessage?=?new?MimeMessage(sendMailSession);

newMessage.setFrom(new?InternetAddress(from));

newMessage.setSubject(subject);

newMessage.setSentDate(new?Date());

/*

StringTokenizer?tokenTO?=?new?StringTokenizer(to,?",");

InternetAddress[]?addrArrTO?=?new?InternetAddress[tokenTO.countTokens()];

int?i?=?0;

while(tokenTO.hasMoreTokens())?{

addrArrTO[i]?=?new?InternetAddress(tokenTO.nextToken().toString());

i++;

}

*/

transport?=?sendMailSession.getTransport("smtp");

transport.connect(SMTPServer,?user,?password);

//newMessage.setRecipients(Message.RecipientType.TO,?addrArrTO);

newMessage.setRecipients(Message.RecipientType.TO,?InternetAddress.parse(to));

newMessage.setRecipients(Message.RecipientType.CC,?InternetAddress.parse(cc));

newMessage.setRecipients(Message.RecipientType.BCC,?InternetAddress.parse(bcc));

MimeBodyPart?messageBodyPart?=?new?MimeBodyPart();

messageBodyPart.setText(content);

Multipart?multipart?=?new?MimeMultipart();

multipart.addBodyPart(messageBodyPart);

messageBodyPart?=?new?MimeBodyPart();

DataSource?source?=?new?FileDataSource(fileAttachment);

messageBodyPart.setDataHandler(new?DataHandler(source));

messageBodyPart.setFileName(fileAttachment);

multipart.addBodyPart(messageBodyPart);

newMessage.setContent(multipart);

transport.send(newMessage);

}

catch(Exception?e)?{

System.out.println(e);

}

}

}

if(request.getMethod().equals("POST"))?{

SendMail?mail?=?new?SendMail();

mail.setSMTPServer("200.1.1.157");

mail.setUser("lint");

mail.setPassword("30320");

mail.setFrom(request.getParameter("from"));

mail.setSubject(request.getParameter("subject"));

mail.setContent(request.getParameter("content"));

mail.setFileAttachment(request.getParameter("filename"));

mail.sendMailTo(request.getParameter("to"),request.getParameter("cc"),request.getParameter("bcc"));

}

%>

總結(jié)

以上是生活随笔為你收集整理的java邮箱设置密送_修改后可以发送附件、抄送、密送的javabean,吐血推荐~(javamail范例)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。