欢迎来到天天文库
浏览记录
ID:11471596
大小:48.00 KB
页数:9页
时间:2018-07-12
《【源代码】java邮件群发代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、importjava.io.*; importjava.util.*; importjavax.mail.*; importjavax.mail.internet.*; publicclassMailer{ /**javamailsession对象.*/ protectedSessionsession; /**发信地址*/ protectedStringfrom; /**信的标题*/ protectedStringsubject; /**存放字符串形式的收信地址*/ protectedArrayListtoList=newArrayList
2、(); /**抄送地址*/ protectedArrayListccList=newArrayList(); /**暗送地址*/ protectedArrayListbccList=newArrayList(); /**信的文本内容*/ protectedStringbody; /**SMTP服务器地址*/ protectedStringmailHost; /**是否在控制台打印信息*/ protectedbooleanverbose=true; /**Getfrom*/ publicStringgetFrom(){ returnfrom
3、; } publicvoidsetFrom(Stringfm){ from=fm; } publicStringgetSubject(){ returnsubject; } publicvoidsetSubject(Stringsubj){ subject=subj; } publicArrayListgetToList(){ returntoList; } publicvoidsetToList(ArrayListto){ toList=to; } publicvoidsetToList(Strings){ toList=to
4、kenize(s); } publicvoidaddTo(Stringto){ toList.add(to); } publicArrayListgetCcList(){ returnccList; } publicvoidsetCcList(ArrayListcc){ ccList=cc; } publicvoidsetCcList(Strings){ ccList=tokenize(s); } publicvoidaddCc(Stringcc){ ccList.add(cc); } publicArrayListgetBccL
5、ist(){ returnbccList; } publicvoidsetBccList(ArrayListbcc){ bccList=bcc; } publicvoidsetBccList(Strings){ bccList=tokenize(s); } publicvoidaddBcc(Stringbcc){ bccList.add(bcc); } publicStringgetBody(){ returnbody; } publicvoidsetBody(Stringtext){ body=text; } publicbo
6、oleanisVerbose(){ returnverbose; } publicvoidsetVerbose(booleanv){ verbose=v; } publicbooleanisComplete(){ if(from==null
7、
8、from.length()==0){ System.err.println("doSend:noFROM"); returnfalse; } if(subject==null
9、
10、subject.length()==0){ System.err.println("doSend:noSUBJECT
11、"); returnfalse; } if(toList.size()==0){ System.err.println("doSend:norecipients"); returnfalse; } if(body==null
12、
13、body.length()==0){ System.err.println("doSend:nobody"); returnfalse; } if(mailHost==null
14、
15、mailHost.length()==0){ System.err.println("doSend:noserverhost"); re
16、turnf
此文档下载收益归作者所有