티스토리 뷰
public Map mailMdn(Map mailMap, List<Map> messageIdList) throws Exception{
Map resultMap=new HashMap<>();
Properties props=new Properties();
props.put("mail.store.protocol","imap");
props.put("mail.imap.host",host);
props.put("mail.imap.port",port);
props.put("mail.imap.auth.plain.disable","true");
Session session=Session.getDefaultInstance(props);
session.setDebug(true);
Store store=session.getStore("imap");
String mailId=mailMap.get("SENDER_MAIL").toString().substring(0,mailMap.get("SENDER_MAIL").toString().indexOf("@"));
store.connect(mailId,"aa");
Folder inbox=store.getFolder("Sent");
inbox.open(Folder.READ_WRITE);
String sentTime=""+System.currentTimeMillis()/1000;
String[] receMail=mailMap.get("RECE_MAIL").toString().split(";");
String[] refMail=null;
String[] hiddenMail=null;
String mId=messageIdList.get(0).get("mId").toString().replaceAll("<","").replaceAll(">","");
if(mailMap.get("REF_MAIL)!=null){
reteMail=mailMap.get("REF_MAIL").toString().split(";");
}
if(mailMap.get("HIDDEN_MAIL)!=null){
hiddenMail=mailMap.get("HIDDEN_MAIL").toString().split(";");
}
MDNVo command=new MDNVo("X-ADDMDN-EX",mId,sentTime,MimeUtility.encodeText(new String(mailMap.get("TITLE").toString().getBytes("UTF-8"), "UTF-8"), "UTF-8","B"));
((IMAPFolder)inbox).do(m);
MDNVo commandOpenMdn=new MDNVo("X-OPENMDN",null);
((IMAPFolder) inbox).doCommand(commandOpenMdn);
for(int i=0;i<receMail.length;i++){
MDNVo commandSetMdn=new MDNVo("X-SETMDN-DB",mId+" "+receMail[i]+" \""+receMail[i].substring(0, receMail[i].indexOf("@"))+"\" "+sentTime+" "+"300");
}
//참조자,숨은참조자 동일
MDNVo commandClose=new MDNVo("X-CLOSEMDN",null);
((IMAPFolder)inbox).do(commandClose);
inbox.close(true);
store.close();
return resultMap;
}
}
//MDN VO를 만든다.
public class MDNVo implements IMAPFoler.ProtocolCommand{
//생성자
public MDNVo(String cmd, String mid, String page, String pageBase, St)
public Object do(IMAPProtocol p) throws Exception{
SimpleDateFormat sdf=new SimpleDateFormat("EEE,dd MMM yyyy HH:mm:ss Z", Locale.US);
Argument args=new Argument();
if(mid!=null){
args.writeAtom(mid);
}
if(page!=null){
args.writeString(page);
}
if(pageBase!=null){
args.writeString(pageBase);
}
if(subject!=null){
args.writeString(subject);
}
if(pattern!=null){
args.writeString(pattern);
}
Response[] r=p.command(cmd,args);
Response response=r[r.length-1];
Response totResponse=null;
Vector v=new Vector();
if(response.isOK()){
if(cmd.equals("X-GETMDN")){
totalResponse=r[r.length-2];
}
for(int i=0,len=r.length;i<len;i++){
if(!(r[i] instanceof IMAPResponse)){
continue;
}
IMAPResponse ir=(IMAPResponse)r[i];
if(ir.getKey()!=null){
String address=ir.readAtomString();
String personal=ir.readAtomString();
String unixTime=ir.readAtomString();
String code=ir.readAtomString();
String readCnt=ir.readAtomString();
if(address==null || address.length()<=0){
break;
}
try{
MDNResponse myMDN=new MDNResponse(personal,address,adf.parse(unixTime));
myMDN.setReadCnt(readCnt);
myMDN.setCode(code);
v.addElement(myMDN);
}catch(Exception e){
}
r[i]=null;
}
}
}
p.notifyResponseHandlers(r);
p.handleResult(response);
return v;
}
}
'자바(Java)' 카테고리의 다른 글
자바 Https 어플리케이션 통신 (SSL) (0) | 2018.10.26 |
---|---|
자바메일(javamail) 관련 (0) | 2018.10.23 |
[자바] 메일 보내기 imap (0) | 2018.10.23 |
자바 첨부파일 포함 메일 보내기 (0) | 2018.10.23 |
[자바] TLS, JKS 로 URL HTTP 통신하기 - 수신 (0) | 2018.10.23 |
- Total
- Today
- Yesterday
- 자바 smtp
- xe addon
- 파이썬
- webix
- 인포믹스
- xe애드온
- 자바
- XE3
- 플러터
- 라이믹스 모듈
- C언어
- 오라클
- MySQL
- 프로씨
- ocjap
- KG
- JDBC
- proc
- php
- 문자열
- 스크래핑
- esql
- 포인터
- XE
- C
- Python
- 이클립스
- EC
- 파싱
- ocajp
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |