问题
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