Reading mail from open source Mirthconnect

我与影子孤独终老i 提交于 2020-01-07 02:54:08

问题


I'm facing an issue with Mirthconnect. I just have a trouble in this process. I like to read the data from mail, is it possible to acheive this in the open source mirthconnect? of version 3.3.1, if so is it possible to read from direct mail?. Apart from the commerical versions like mirth mails.


回答1:


I made use of JAVA mail library and inserted it in the custom library folder of mirth connect then used the following code in the connector portion of mirth. It works well.

  //Fetchmail from Gmail
  var props = new Packages.java.util.Properties();
  props.setProperty("mail.store.protocol", "imaps");
  var session = new Packages.javax.mail.Session.getInstance(props, null);
  var store = session.getStore();
  store.connect("imap.gmail.com", "xxxxxxxx@gmail.com", "xxxxxxxxx");
  var inbox = store.getFolder("INBOX");
  inbox.open(Packages.javax.mail.Folder.READ_ONLY);
  var msgs = inbox.getMessage(inbox.getMessageCount());
  var currentMessage = inbox.getMessage(inbox.getMessageCount());
  var mp = currentMessage.getContent();
  var bp = mp.getBodyPart(0);
  var content = "" + bp.getContent();
  content = content.replace(/''/g, "");
  globalMap.put('gcon', content);
  logger.info("SENT DATE:" + msgs.getSentDate());
  logger.info("SUBJECT:" + msgs.getSubject());
  logger.info("CONTENT:" + content);
  //bp.getContent()  
  var receiveId = UUIDGenerator.getUUID(); 
  logger.info("incomingMailID : "+receiveId);
  //Database Connectivity
  var time= msgs.getSentDate();
  var con = bp.getContent();
  var sub = msgs.getSubject();
 //global variable declaration
  globalMap.put('glcontent',con);
  globalMap.put('glsubject',sub);
  globalMap.put('gltime',time);
  return sub;

Then you can set the the polling frequency time intervalin the listener which the mirth channel will poll for that specific time interval.



来源:https://stackoverflow.com/questions/34394775/reading-mail-from-open-source-mirthconnect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!