Reading emails through javaMail library with Mirth Connect

[亡魂溺海] 提交于 2019-12-12 05:28:47

问题


My goal is to read emails(and possibly mark them as read in the inbox) through Mirth Connect channels. I found this Reading mail from open source Mirthconnect question about the issue. Oddly the person asking answered the question. When I tried to implement the code he provided with my specifications such as instead of gmail outlook inbox(no problems here) the channel called out error:

64DETAILS:
    TypeError: Cannot find function getBodyPart in object <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi!</div>...(here the email continues with div tags)

So I clearly get the email data but getBodyPart breaks it. What I understood from this is that his code was meant for specific kind of emails and I guess I received an non-mime email in the example here.

So it seems what I am asking: How do I create a reader that translates all mail into plain text and then output it into the logger/other output so I can manage it?

Management would mean something like spreading specifically titled mail into different channels and mark them read in the inbox they came from.

I hope I'm clear enough with my question and follow the rules of asking questions.


回答1:


I am answering to your updated query.This program will be reading the email repeatedly as you mentioned is correct so as to avoid this after reading you need to move the email to other folder and also you can customise your program to read from particular email sender or based on subject so that it reads only your particular email and you can move that email to you wished folder.




回答2:


I was the one whom you mentioned in the code. When I tried to fetch the mail from GMAIL also I faced the same issue. But I checked the security apps OFF, I have provided the link here for GMAIL. I guess something like this must be available for outlook as well. But I have tried the same code to read in my outlook it worked fine without any changes been made (not sure how?).

For GMAIL Security OFF https://myaccount.google.com/lesssecureapps

It depends on the kind of mail your are reading. In my case I was getting HTML designed data in the body of the mail.That code was not generalized one. It is supposed to read HTML data in mail body.I'm not sure how your mail is?. But mp.getBodyPart(0) or mp.getBodyPart(1) should provide some output. Even if you attach the file in the mail, mp.getBodyPart will read the attachment.



来源:https://stackoverflow.com/questions/45034377/reading-emails-through-javamail-library-with-mirth-connect

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