OpenESB - EmailBC: Attached File - email

I'm working on a BPEL in OpenESB for sending emails with attachment files.
I have installed the email binding component and I followed the steps described in the manual, so now my BPEL is able to send an email with an attachment file.
I have added the option SMTPAttachemnt in the binding as you can see in the image :
But I have a problem because the bpel receives a base64 encode file, so when I check my email inbox the file attached remains encode :(
So I think if I want to receive the file decoded in my email inbox, I would have to decode the "attachedFile" element before sending the email. My question is: what's the best way to decode the a base64 encode file element in OpenESB ?
Thanks in advance!!
I will look forward to hearing your solutions,
Girish

You can use direct java call from BPEL itself. on java-6, we use it like
DatatypeConverter.parseBase64Binary("encoded="); just map input and outputs.

Related

How do I write .DXL formatted email to disk?

I am trying to convert Lotus Notes email to MIME format. I found this article to be helpful although I am using Lotusscript not Java. The problem I am running into is that this article does not say how you write the .dxl output to disc as an .eml file. if I use the following notesstream method:
rc2 = strmOutput.WriteText(mimeDoc)
it works but any graphics or attachments that were in the original email are not there. emails that contain attachments don't get written at all. emails that had graphics in them get written but there is a placeholder for the graphics in the resultant .eml file instead of the actual graphic. I have not figured out how to successfully capture all of the graphics and attachments so that everything that was in the original email appears in the .eml file. I have been trying to figure this out for months. if someone could elaborate on this that would be great
I was expecting the graphics and attachments to be in the resultant .eml file but they are not there

How to select a URL from an email in mutt and open it in a web browser?

When I read mails I sometimes would like to select one of the links in the mail's text to open it in a web browser.
Before you answer, I know there is urlview, but there are also BASE64-encoded (or other transfer encodings) mails from which urlview does not find any URLs. Then there are also HTML-only mails that can also be encoded with transfer encodings.
I wonder if there is a trivial and/or nice solution that I couldn't find. I cannot be the only one with this problem. It does not need to be based on urlview, of course.
urlview will work if you employ the "pipe_decode" setting. Example use in a macro, binding to "\u":
macro index,pager \\u "<enter-command>set pipe_decode = yes<enter><pipe-message>urlview<enter><enter-command>set pipe_decode = no<enter>" "view URLs"
with urlscan there exists a worthy successor to urlview.
Support for emails in quoted-printable and base64 encodings. [..] For HTML mails, a crude parser is used to render the HTML into text.

Converting JPEG in text format from email message source back into JPEG

I received an email a while ago with an image attachment in it. Since then, it seems hotmail has stopped hosting the image for me as when I open the message, the image is no longer available.
However, the message source is still intact, and if I'm not wrong, the message source - in text form - also contains the image.
The problem is of course it is in text form. The part which (I believe) contains the image looks something like this: (Just the first few lines)
--Apple-Mail-2--733971985
Content-Disposition: inline; filename=photo.JPG Content-Id:
<3F8BDC26-81F3-4BA2-9071-53E78CB3DB63/photo.JPG>
Content-Type: image/jpeg; name=photo.JPG Content-Transfer-Encoding:
base64
/9j/4AAQSkZJRgABAQEASABIAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdC
IFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAA
AADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFj
cHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAA
ABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAAD
TAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJD
It was sent from my iPhone into Hotmail.
Is this text representing the image that I am missing? I don't believe there is a program out there that can convert this for me, so I am willing to write my own program to do it. Question is, is this even possible?
Yes, this is entirely possible, by various methods. If you have the entire message source, you could save it into a file (something like *.eml) and open it in a mail client (e.g. Mozilla Thunderbird); this should show you the entire message including the attached image.
If not, it's still possible: as you can see from the headers, the image is base64-encoded. You need to revert this transformation - either using your own code (e.g. PHP has base64_decode()), or through various base64-decoders available online (e.g. this). The part you want to decode is the block starting with /9j/4AAQSk in this case. Rename the resulting file photo.JPG (as indicated in the e-mail headers) and you're done.
Note that this requires you to verify that you have put the entire base64-encoded file through the decoder - base64 has no marker to detect the end of file.

Create Byte Array from GWT File upload Input

I have a .NET web service that takes a byte array.
I have a GWT client where I want the user to select a file using the FileUpload control and send it to the web service via HTTP stream.
The file upload control contains a method to get the file path of the selected file. How can I then get that file and convert it to a byte array?
I'm open to suggestions on how to get the file to my web service, not quite sure the Byte array will work...
If you want to convert the file in GWT, meaning in the browser. It's not possible to do in the browser using only JavaScript. FileUpload is a html input type file upload can only send the file to a server as in submit a form. For security reasons browsers can't read files from your file system. (You could use a plugin like a flash plugin to get it to work, although I have no examples at hand).
If you want to send the file content to your webservice, you need to or upload it directly to the webservice or send it to another server, convert it and from that server submit it to your webservice or write or find some (flash) plugin that does it for you.
This link maybe helpful yo you How to convert a byte array to a string, and string to a byte array with GWT
The String(byte[] bytes) constructor and String.getBytes() method are not implemented by GWT JRE emulation String class.
This is not possible purely in Javascript(yet) but could be done with flash or a signed applet. Personally what I would do is create a signed applet that would be somewhere on the page but not visible. When the user selects a file to send to the server you would get the file location from the input and send it to the applet which will load the file and return the data to Javascript as a byte array. If you are flexable with changing the web service to accept multi-part form data then you can do so and just include the file upload field as part of a form and submit the form. Now what you want to do is possible with HTML5 and a demonstration can be seen here, so if you are capable of specifying that the users be using at least a semi-HTML5 compliant browser such as FF3.6 or Chrome 6 you may be in luck.

Display local image in iPhone HTML mail

In my app, I am composing an HMTL email message with the 3.0+ MFMailComposeViewController.
To do this, I created an HTML file, with some placeholders.
In my code, I read the HTML file, and with replaceOccurrencesOfString, I replace the placeholders with data from the app.
In that way, I compose the body of the email I want to send out.
This is all working very nicely, except for the fact, that in my HTML file, I have an <img src='imageplaceholderpath' /> tag.
Somehow, I cannot figure out, with what I should replace this imageplaceholderpath, in order to refer to an image that resides in my app.
Is this a valid approach at all, and if so, what would be the syntax/logic behind the path I should put there?
I do appreciate your insights!
Regards
Sjakelien
Unfortunately this is not supported by the iPhone 3.x APIs.
http://developer.apple.com/iphone/library/documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html
It would require Content-ID: to be part of the attachment subpart but it is not.
- (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
Note that using data: URIs won't work across all mail clients. Those that use IE as a rendering engine don't support it at all unless IE8 is installed, and even then, according to Wikipedia, data: URIs are limited to 32 KB maximum.
The very simplest way to get this to work is to put the image on your own server somewhere, and reference it using a full http:// URI. If you can't do that for some reason (maybe the image is generated as part of using your app), then you can try attaching the image as a MIME sub-part and referencing it from the HTML.
My mail client doesn't load remote images automatically, but some spam still has images when I open it. This is how it works:
Attach an image to your mail as suggested by yonel. Somehow you need to also add a Content-ID: header to the sub-part. The contents of this header are then used as the src attribute on your image. My spam message looks like this in the HTML:
<img src="cid:image001.jpg#01CACC43.7035CE50">
The attachment sub-part looks like:
Content-Type: image/jpeg;
name="image001.jpg"
Content-Transfer-Encoding: base64
Content-ID: <image001.jpg#01CACC43.7035CE50>
Looking at the documentation for addAttachmentData:mimeType:fileName:, my guess is that you won't be able to get this to work and will have to consider sending the email using raw SMTP.
I found this post, that answers most of my questions: http://www.iphonedevsdk.com/forum/iphone-sdk-development/25021-embedding-image-email-body.html.
I don't think you can embed the images as part of the email in the way a normal email client would. However it seems that you can include the image data directly in the HTML as base64 encoded data. This is quite a non-standard way of doing things, so the email might not display perfectly on all email clients.
See this question for more, and the sample code on this forum post
I don't know if the HTML format is a must have for you, but actually embedding an image in an email can be achieved without using HTML, just with image as attachment.
Just have a look at the way it is achieved here :
http://iphone-dev-tips.alterplay.com/2009/11/attaching-image-of-uiview-to-email.html
the crucial part is this :
// ATTACHING A SCREENSHOT
NSData *myData = UIImagePNGRepresentation(screenshot);
[controller addAttachmentData:myData mimeType:#"image/png" fileName:#"route"];
You get the PNG representation of your UIImage (as NSData) and you attach it yo your email.