Situation:
The System is fetching Emails via standard methods (Pop3) from a Mailserver and sends them to the Archiving component as multi-part messages (*.eml files).
If the mail was sent from Outlook it may contain an OLE-Object for example a MS Word, MS Excel and so on. There are several ways to include such an Object, for example via Menu "Insert->Object"
Problem:
Our requirement is now to extract those OLE-Objects archive them as separate attachments. It would be best to do it in Java or other JVM Languages. Other Languages and Frameworks would be possible but they must be working on different platforms (Win, Linux, Unix)
The problem is we haven't found any library or functions in the libraries to do this.
First issue is, that the message the receiver gets depends on how outlook is configured:
It may send RTF messages: Then the receiver get's a message having an attachment "Untitled Attachment.bin"
It may send HTML messages: Then the receiver get's a message inlcuding an attachment "oledata.mso".
What we've tried so far:
We tried Apache POI, especially POIFS to load the file "oledata.mso" but it complained about that some header value is wrong:
Invalid header signature; read 0xD7EC9C7800013000, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document
We found a website talking about the same issue. As far as we understood, the oledata.mso is an collection of Compound File Binary Files. Which should also be parsable with POI individually because the OpenMCDF is doing the same things as POI.
On this website they somehow separate the parts and parse them separatly. But we haven't found a similar function or any specification how this is done.
Can anybody please shed some light on this?
Related
Whilst this isn't directly a programming question, the answer will highly influence the solution adopted.
I am looking at developing a Java client to transfer data (files) into Informatica Powercentre Web Services Hub (WSH). Best practice suggests to use MTOM for large files being sent via SOAP requests.
I'm assuming support for consuming MTOM attachments is vendor specific, one can't assume it works out of the box ?
If anyone can confirm whether Power Center 9.x supports this, it'd be muchly appreciated. I've spent a lot of time on the Informatica Communities and reading documents but it is rather opaque to say the least.
RTFM
It appears that MTOM is not supported. From PowerCenter WebServices Provider Guide v 9.0.1 page 80 "WSDL Attachments".
The attachment must be a text file such as an XML document. You cannot attach binary documents... To use a binary file as a source, convert the file into hexbinary or base64binary before you pass it to the web service source. A hexbinary or base64binary files is treated as a text file.
I have a program that must 'prepare' emails for me. When the email is prepared, it should show in outlook (or an other email client - default user mail client).
I have used the Desktop.getDesktop().mail approach, but I'm very limited with the options. (I cannot set the high importance). An other option I've tried is JavaMail. But here the mail will be send instead of opened in the email client. (same for Apache POI).
An other option I've considered is to write a .msg/.eml file and open it, but this must be done manually (via java I get a 'file not found' error or an error regarding privileges).
Does anyone know other options or other approaches I might have missed / overlooked?
You can make use of moyosoft's connector to access outlook functionality from java. Please refer to below url's for more details on this.
http://www.moyosoft.com/joc/
http://www.moyosoft.com/joc/getstarted/
I need the solution for the below problem in Java -
On arrival of new mail in ms outlook for a particular email id, there should be a web service get executed automatically.
is it possible? please help!
You can do that using java mail. You will need to find the configuration details but a standard code snippet for this would be something like below. I copied the code snipped from here. Thos official javamail link has a pretty decent set of examples (ie. how to read attachments).
For storing the email as a file to a folder, you can apache FileUtils. Write the email to a file and copy it to a folder that you desire.
There is one more interesting resource
In Java, how to launch the mail client along with the given file as its attachment - particularly using the method Desktop.getDesktop().mail(URI)
I am using Windows 7 and want to launch MS Outlook.
It is a good question.
Indeed the URI that sent as a parameter to method desktop.mail(URI) allows setting to, cc, bcc, subject, body and does not allow setting attachments. (see http://www.ietf.org/rfc/rfc2368.txt)
However attachments are actually specially formatted fragments of email body. Please read this for more details: http://techhelp.santovec.us/decode.htm.
This means that you can encode your binary attachment using Base64 and create email body that already contains the attachment of any generic file. I personally have not tried this but I believe it must work. Good luck.
As far as I know, it is unfortunatly not possible to specify any attachment using Desktop.mail(URI).
I've tried AlexR suggestion. It doesn't work if the file is too big because of the restriction of the number of characters in the URI.
However, it is still possible using JMAPI, though it only works on x86 platforms.
The ultimate way to make it work is using the JavaMail API, but it forces you to create your own GUI and to set the SMTP server configuration.. which is not pretty user-friendly.
If anyone as other suggestions, i'd be glad to know them.
I am trying to send an email with Java, I am using apache commons email library.
I cannot achieve to send an email with a body as HTML and an attachment as PDF (or any file type)
If I use EmailAttachment() and add it to an HtmlEmail object, my mail looks like with two attachment. First one is for HTML, second is for PDF.
Is there any way to do that?
Thank you very much!
It sounds like relatively normal behaviour for a message that's being sent as both text and HTML, and/or a mail client (at the receiving end) that prefers text emails. I suspect that this is due to the behaviour of the client, which you won't be able to change (but on the plus side all HTML emails would appear like this).
The thing is, an HTML email (with a textual component) really is a multipart message, with the HTML content as one of the "extra" parts. All you're actually sending in the email from the server side is a bunch of text, and it's up to the receiving mail client to decide how to display it. In that respect, it is not wrong for the client to display your HTML as an attachment - just like it is not wrong for a smart client to infer that the HTML isn't a "real" attachment and activate some kind of toggle between text and HTML (rather than displaying it as an attachment).
If you're convinced that the client would normally treat HTML in this smart way, then:
You'll have to mention which client you're using to check, because this isn't really an issue with the sending per se; and
You might want to take a look at the raw source of email that "works", and your email that doesn't, in order to determine what the critical differences are that trigger the different rendering modes. Depending on the client software, this could be just about anything - but I'd pay particular attention to part MIME types and charsets.
I tried apache commons mail v1.2 instead of 1.1.
It works!?
Andrej, by the way many thanks for your kindly help.