Adding in-memory images to multipart/related
I'm constructing a multipart/related message and would like to add in-memory images to the MimeBodyPary instead of having JavaMail grab the images from the file system or from a URL.
Is there a simple way to do this using the JavaMail API? I think the solution might be to add a new DataSource implementation to the activation framework; something like a ByteArrayDataSource....
Yes, that is the solution.
Similar Messages
-
How to send HTML mail with images multipart/related message
Hi,
Could any body tell me how to send HTML mail with images in "multipart/related" message,if any body can give the code ,it would be helpful.
ThanksHi,
Could any body tell me how to send HTML mail with
ith images in "multipart/related" message,if any body
can give the code ,it would be helpful.
ThanksHi!
Refer to
http://developer.java.sun.com/developer/onlineTraining/JavaMail/index.html
I've found it very helpful.
Look at the last part for a code showing how to send HTML mail!
Regards -
MIME Multipart/related to embed images in html files - Servlet
Hello,
My goal is to embed images in html/xhtml files to decrease latency when using slow networks. Think about mobile phones, if I have 10 images in one page, I will have 11 requests/responses to get the whole page.
The solution would be to embed all images using Content-type multipart/related, so I have one request to the whole pack.
How to do that in java? I mean, I need to set the content-type and build all parts encoding the images to base64.
I tried JavaMail API, there I can build messages like this and instead of send an e-mail, I can write:
myMimeMultipart.writeTo(response.getOutputStream());
The problem is: I am getting everything as text in my browser, including the MIME headers of each part. Another think is that the first header (the main one) doesn't appear too.
Any thoughts/other ideas?
Thanks in advance,
Andr� CarlucciIf memory serves me right, I believe in the Servlet spec you have access to the Response object. You "should" be able to set any headers you need there. In addition, you can get the output streams just as you described.
I did a similar thing, although slightly modified, to output dynamically-generated XLS (Excel Spreadsheet) files using a reporting engine called JasperReports. It wasn't a multipart response, however, so you may need to figure out how to handle that part of it, but in my case I set the mime-type header, then grabbed the output and started writing my XLS file too it. Once done, you close the streams and return the response. Worked perfect. -
OSB defaulting Content-Type to "multipart/related" in case of attachments
I have scenario where I need to invoke a REST Webservice from OSB which accepts only media types which has "multipart/atom+xml". OSB is used for protocol transformation converting the SOAP request into the HTTP POST request with multipart. I have Proxy Service which will unwrap the message from the SOAP Body and post the same message into the payload of the Business Service and the attachment is passed 'as is' from the SOAP Service. The external REST Service Provider expects the media type to be "multipart/atom+xml", but in OSB when an attachment is present in the message, OSB is overrding the "Content-Type" proeprty to "multipart/related" inspite of me setting the "Content-Type" property of HTTP Transport Header in OSB and as result external RESTFUL Service is throwing "415-Unsupported Media Type" error. Below is the test results. One interesting thing is, it happens only when there is attachment present in the message. In case of a message which doesn't have attachment any "Content-Type" specified in the Transport Header is passed by the OSB to the external service. Any help is highly appreciated.
OSB Transport Header
Added the header <http:Content-Type>multipart/atom+xml</http:Content-Type>
Actual Raw Message
POST http://xxx7200:7004/XXXInterfaces/identify HTTP/1.1
Content-Type: multipart/related; type="text/plain"; start="<Root_-328322390>"; boundary=MIME_Boundary; charset=UTF-8
MIME-Version: 1.0
User-Agent: Java1.6.0_17
Host: xxx7200:7004
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Proxy-Connection: Keep-Alive
Content-Length: 4823
Expected Raw Message
POST http://xxx7200:7004/XXXInterfaces/identify HTTP/1.1
Content-Type: multipart/atom+xml; boundary=MIME_Boundary;
User-Agent: Java1.6.0_17
Host: xxx7200:7004
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Proxy-Connection: Keep-Alive
Content-Length: 4803
-KC
Edited by: 799459 on Apr 8, 2011 5:36 AM
Edited by: 799459 on Apr 8, 2011 7:02 AM
Edited by: 799459 on Apr 8, 2011 7:13 AM
Edited by: 799459 on Apr 8, 2011 7:14 AMHTTP content-type header has the following limitation as per osb doc.
Oracle Service Bus run time may overwrite these headers in the binding layer when preparing the message for dispatch. If these headers are modified, $inbound and $outbound are updated accordingly. So what you are seeing may be working as designed. Cant the remote service accept the multi part related content type set up by osb ? -
Hi guys!
My first time on here so I hope this goes well!!
Ok, I'm on here because I have a problem. Basic jist of it is this. I'm trying to create a program which will read in emails. Everything was super until i recieved an email with the content type set as:
multipart related; type="multipart/alternative";
Any ideas as to how I can handle this because I'm totally stuck.
Thanks people!Ah, that is the next mime type I need to implement for the webmail at webmail.ufl.edu that we're developing. When adding support for different mime types I found http://www.iana.org/assignments/media-types/ to be very useful. RFC2387 http://www.rfc-editor.org/rfc/rfc2387.txt describes multipart/related. Below is my current understanding, I could be wrong:
Basicly you'll find a few parameters: type, start, and start-info.
The start parameter may have a value that is a content-ID. If it does then that is the first part to show to the user, in most cases these days it will be the content-ID of a part of text/html and the other parts will be images. If the start parameter doesn't exists you use the first part inside the multipart/related.
The type parameter is required and it will be equal to the content-type of the "start" part. It's here so you don't have to look ahead too see what time time you're going to display to the user. I think I'll be ignoring it infavor of looking directly at the part but I don't know yet.
I'll let your read the RFC for info on start-info. It's optional and I don't think you're gonna need to worry about it unless you plan to fork processes to view a part.
So to display multipart/related you find your start part and present that to the user. All other nested parts you supress unless the start part requires them. In the case of a text/html start part you'll want to rewrite any <img src="cid:foo"> tags to something that references one of the image parts so it can be displayed inline in the html.
Hope that helps. If I found myself to be wrong I'll put up a follow up post. -
Multipart/related part specifiers
Hi, this query is perhaps the result of my own limited knowledge regarding MIME types and part specifiers but here goes....
Based on the following BODYSTRUCTURE, I am attempting to determine the associated part specifiers so I may get the MIME headers for said part (i.e. A12 UID FETCH 147859 (BODY.PEEK[1.MIME])).
A11 UID FETCH 147859 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "QUOTED-PRINTABLE" 911 16 NIL NIL NIL)(("TEXT" "HTML" ("CHARSET" "US-ASCII") NIL NIL "QUOTED-PRINTABLE" 2716 46 NIL NIL NIL)("IMAGE" "BMP" ("name" "ExchangeBabs.bmp") "<297231021@11102006-1D66>" NIL "BASE64" 2634474 NIL ("inline" ("filename" "ExchangeBabs.bmp")) NIL)("APPLICATION" "OCTET-STREAM" ("name" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG") NIL NIL "BASE64" 732 NIL ("inline" ("filename" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG")) NIL)("IMAGE" "GIF" ("name" "Blank Bkgrd.gif") "<297231021@11102006-1D6D>" NIL "BASE64" 202 NIL ("inline" ("filename" "Blank Bkgrd.gif")) NIL) "related" ("boundary" "-------45363d5545363d55") NIL NIL) "alternative" ("boundary" "-------446e3c8d446e3c8d") NIL NIL) UID 147859)
The com.sun.mail.imap.protocol.BODYSTRUCTURE object generated is shown below (I've omitted most of the fields and left what I considered relevent, simply enough to show the nesting):
bs= BODYSTRUCTURE (id=181)
bodies= BODYSTRUCTURE[2] (id=199)
[0]= BODYSTRUCTURE (id=207)
bodies= null
encoding= "QUOTED-PRINTABLE"
subtype= "PLAIN"
type= "TEXT"
[1]= BODYSTRUCTURE (id=208)
bodies= BODYSTRUCTURE[4] (id=213)
[0]= BODYSTRUCTURE (id=216)
bodies= null
encoding= "QUOTED-PRINTABLE"
subtype= "HTML"
type= "TEXT"
[1]= BODYSTRUCTURE (id=217)
bodies= null
encoding= "BASE64"
subtype= "BMP"
type= "IMAGE"
[2]= BODYSTRUCTURE (id=218)
bodies= null
encoding= "BASE64"
subtype= "OCTET-STREAM"
type= "APPLICATION"
[3]= BODYSTRUCTURE (id=219)
bodies= null
encoding= "BASE64"
subtype= "GIF"
type= "IMAGE"
subtype= "related"
type= "multipart"
subtype= "alternative"
type= "multipart"This particular message has a multipart/related content-type:
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----_=_NextPart_001_01C6ED7A.EC20BF80"So, it has 4 part specifiers, one for each part in multipart/related. Now, the question to all this is can I determine from the BODYSTRUCTURE object what the root part is (i.e. that it's multipart/related)? Or am I going about this the wrong way (i.e. should I be examining the content-type header first to find out that its multipart/related and the first part is "text/html")?Basically, I'm trying to fetch various attributes of a message. In this case, the MIME headers of the various message parts (perhaps I'm stating the obvious but I'm not sure how to better explain what I'm trying to accomplish).
I've made some "progress". This morning when I continued working with the message described above, all of a sudden, the BODYSTRUCTURE I get back is different and as a result, the BODYSTRUCTURE object generated is different.
1 uid fetch 148032 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE (("TEXT" "HTML" ("charset" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 2792 47 NIL NIL NIL)("IMAGE" "GIF" ("name" "Blank Bkgrd.gif") "<297231021@11102006-1D6D>" "Blank Bkgrd.gif" "BASE64" 202 NIL ("inline" ("filename" "Blank Bkgrd.gif")) NIL)("IMAGE" "BMP" ("name" "ExchangeBabs.bmp") "<297231021@11102006-1D66>" "ExchangeBabs.bmp" "BASE64" 2630728 NIL ("inline" ("filename" "ExchangeBabs.bmp")) NIL)("APPLICATION" "OCTET-STREAM" ("name" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG") NIL "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG" "BASE64" 732 NIL ("inline" ("filename" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG")) NIL) "related" ("type" "text/html" "boundary" "----_=_NextPart_001_01C6ED7A.EC20BF80") NIL NIL) UID 148032)
1 OK FETCH completed.
bs= BODYSTRUCTURE (id=89)
bodies= BODYSTRUCTURE[4] (id=104)
[0]= BODYSTRUCTURE (id=115)
bodies= null
encoding= "QUOTED-PRINTABLE"
subtype= "HTML"
type= "TEXT"
[1]= BODYSTRUCTURE (id=116)
bodies= null
encoding= "BASE64"
subtype= "GIF"
type= "IMAGE"
[2]= BODYSTRUCTURE (id=117)
bodies= null
encoding= "BASE64"
subtype= "BMP"
type= "IMAGE"
[3]= BODYSTRUCTURE (id=118)
bodies= null
encoding= "BASE64"
subtype= "OCTET-STREAM"
type= "APPLICATION"
encoding= null
subtype= "related"
type= "multipart"NOTE: The UID differs from the previous example I'd given because I had archived the message and then moved it back to my Inbox.
Any ideas why the BODYSTRUCTURE reported by the server today is different from what it reported before? I have this message on both an Exchange 2000 and Mirapoint server. 2 days ago they both reported the BODYSTRUCTURE I indicated before, now they both have the BODYSTRUCTURE above.
PS. Sorry that this issue isn't really Javamail related anymore but I'd appreciate any input. -
No object DCH for MIME type multipart/related
Hi, everyone!!!
When I execute my code, I got this exception:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/related
boundary="----=_Part_0_20851530.1186777547859"
the funny things is : I got it work before. However, when I come back a few days to run, it doesn't.
I use tomcat 5.0,
mail.jar: version: 1.6
activation.jar:version: I don't know but I download the new ones in sun website.
Note: Also, when I run the code below in standalone application (java application), it works but doesn't work on tomcat application
Any help would be appreciate.
I tried some helps tips from other website such as http://www.jguru.com/faq/view.jsp?EID=237257
and still doesn't work :((((
***********Here is my code**********
********props is properties file...............
Authenticator auth = new SMTPAuthenticator();
// Get session
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(true);
// Create the message
Message message = new MimeMessage(session);
// Fill its headers
message.setSubject(subject);
message.setFrom(new InternetAddress(from));
for(int x=0;x<recipients.size();x++)
message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipients.get(x).toString()));
// Create your new message part
BodyPart messBodyPart=new MimeBodyPart();
// Set the HTML content, be sure it references the attachment
String htmlText="<h1>Hi</h1>"+"<img src=\"cid:picture\">";
// Set the content of the body part
messBodyPart.setContent(htmlText, "text/html");
// Create a related multi-part to combine the parts
MimeMultipart multipart=new MimeMultipart("related");
// Add body part to multipart
multipart.addBodyPart(messBodyPart);
// Create part for the image
messBodyPart=new MimeBodyPart();
// Fetch the image and associate to part
System.out.println("before dataSource");
DataSource fds=new FileDataSource(this.getString("image_location"));
System.out.println("After dataSource");
messBodyPart.setDataHandler(new DataHandler(fds));
System.out.println("*************** dataSource");
// Add a header to connect to the HTML
messBodyPart.setHeader("Content-ID", "<picture>");
// Add part to multi-part
multipart.addBodyPart(messBodyPart);
// Associate multi-part with message
message.setContent(multipart);
// Send message
System.out.println("Before Send");
Transport.send(message);
System.out.println("Finish");
}Thank you for your response!!!
I already found the solution. For those who still having problem send e-mail, make sure to put mail.jar and activation.jar in the same location.
Also, make sure to check catalina.xml to make sure those jars are same location!!!->That what I found out.
->I put jars in same location of my eclipse project but it turns out, the tomcat app server didn't put them in same location.
Anyway, Thank you java_2006 for your response!!!!!
:) -
Mkinitcpio WARNING: No modules were added to the image.
I am trying to build a pf-kernel using this guide: https://wiki.archlinux.org/index.php/Ke … raditional
Everything went fine, but when I try to make the initramfs, I get this error:
mkinitcpio -k 3.13.3-pf-dbb-pf+ -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-dbb-pf.img
==> Starting build: 3.13.3-pf-dbb-pf+
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> WARNING: No modules were added to the image. This is probably not what you want.
==> Creating lz4 initcpio image: /boot/initramfs-linux-dbb-pf.img
==> Image generation successful
I searched the warning message, but all the posts I found were related to other errors, like a "module not found" or so. As you can see, I'm not getting any actual error message, just the warning.
Is this message just because the MODULES line of mkinitcpio.conf is blank, or something else?I definitely ran `make modules_install`. Twice actually, because I thought something went wrong the first time.
A find command shows that there are some modules, but only a handful. My guess is that I forgot to copy a good config before running menuconfig, so I'll try building again.
I was wondering why it only took 10 minutes to build. -
I am adding more memory, should I replace the top two slots with the 4g memory modules, then place 2g memory modules on bottom slots. Does it even matter?
I am adding more memory, should I replace the top two slots with the 4g memory modules, then place 2g memory modules on bottom slots. Does it even matter?
-
I have a Macbook Air. I have MS office installed and work in Excel often with no issues. But When I download an excel spread sheet from a Ford web site I seem to be getting code and not the work sheet.
Example-
MIME-Version: 1.0
X-Document-Type: Workbook
Content-Type: multipart/related; boundary="====Boundary===="
--====Boundary====
Content-Location: file:///C:/HOLD.XHT
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<meta name="Excel Workbook Frameset">
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>BTB</x:Name>
<x:WorksheetSource HRef="./IBIT0001.xht"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>GSM</x:Name>
<x:WorksheetSource HRef="./IBIT0002.xht"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>RODetail</x:Name>
<x:WorksheetSource HRef="./IBIT0003.xht"/>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</HEAD>
</HTML>
--====Boundary====
Content-Location: file:///C:/IBIT0001.xht
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-page-orientation:landscape;}
tr
{mso-height-source:auto;}
col
{mso-width-source:auto;}
br
{mso-data-placement:same-cell;}
.style21
{color:blue;
font-size:10.0pt;
font-weight:400;
font-style:normal;
text-decoration:underline;
text-underline-style:single;
font-family:Arial;Try search/ask in the forum devoted entirely to Excel issues:
http://answers.microsoft.com/en-us/mac/forum/macexcel -
New Zen trouble adding a memory card (not seen)?
0New Zen trouble adding a memory card (not seen)?8I have a new zen 4gb unit and love it, saw it has a memory card slot so i stuck an 8gb sdhc sandisk 3 extreme memory card in there, figured I could dump more fun stuff in there on it but when i use the zen explorer i don't see that card.
I formatted the sdhc card in fat 32 and named it sd4zen yet when its in the zen and i check my computer I am not seeing the card in the windows menus to drag stuff over onto for the zen nor is it showing in any of the zen media explorer areas.
Do i need to dump stuff onto the memory card externally (thru a card reader first) then insert it and access that thru the memory part of the zen menu, or are the zens not able to read from an sdhc sd card or is 8 gb too big (compatability)?
Thanks for any help on this,
BillI am a dork, a few mins messing with it i realized in the main menu of the zen with the card inserted hit removable disk and hook up via usb, now my computer sees the sd4zen dri've and i can dump more fun stuff for zen on there...
Sorry to take up space maybe someone will read this and help them with the same issue i was having or mods if you choose just delete.
Bill -
Is it possible to put a drop shadow on text added to an image?
Is it possible to put a drop shadow on text added to an image using Photoshop Elements 10?
Yes.
Open the Effects palette. In the drop-down. go to "Drop Shadows." You will find several listed. After you have applied, double click on the f on the text layer in the layers palette. This will bring up the Style Settings. Here you can fine-tune the shadow..
Note that in the drop-down referenced above, there are also Bevels which may enhance your presentation. -
IbookG3 wont recognize memory stick or burn disks after adding more memory
I recently added more memory to my old ibook. Now when I put my memory stick in either USB ports nothing comes up on the desktop. I also can't get anything to burn onto disc. Any ideas?
Hi, and welcome to Apple Discussions.
Have you tried removing the RAM to see if those capabilities return to the iBook?
How big is the hard drive and how much space remains available on it? -
Is there anyway of adding more memory to an iPod touch?
Is there anyway of adding more memory to an iPod touch as I am running out of space.
Thank youIt's annoying because the amount of memory apple advertise is not actually all for you to use. I bought an 8g iPod thinking it would be enough but didn't realise 2g of the 8g is already used for you!
-
I am working on an extended IMAQ Display control using LabVIEWs XControl capabilities.
I need a copy of the original image passed to add some overlays which must not affect the original image. To achieve this I am creating a backup image in the "Init.vi" and deleting it in the "Uninit.vi". I am storing the reference of this image in the "Display State.ctl" which is part of every XControl.
As soon as I am adding an "IMAQ Image.ctl" to the Display State cluster, it is no longer possible to generate a probe of the Display State cluster for debugging purposses. I am always getting the message: "Failed to load or create probe."
Deleting the "IMAQ Image.ctl" from the cluster makes the probe working again.
Is it a bug or am I doing something wrong?
I am working with LabVIEW 8.5 and Vision 8.5.
Regards
Ingo BartschHello Mr. Bartsch,
is it possible for you to post a small example to reproduce the behaviour? It would be helpful to get a description in which way you use the typedef files.
I found a example/knowledge base where some informations were included to XControl and LV but not with Vision.
http://digital.ni.com/public.nsf/allkb/1DC1ADD2A136DA298625712C00635758?OpenDocument
Best wishes
Jan Kniewasser
Jan Kniewasser | Applications Engineer | Tel.: +49 89 7413130 | Fax: +49 89 7146035
Maybe you are looking for
-
CAD Desktop - Check out problem
Hello all, IN productive system, user trying to check out the drawing from Content server. But system is showing an error message "ERROR WHILE CHECKING IN AND STORING:C\SAPWORKDIR\ACADM\1110002546 (dir no). 1. Content server is active & RFC connectic
-
We have a DVD in the super drive on our Macbook Pro that will not eject. The DVD does not show up on the desktop. Have tried the keyboard eject button, and also restarting the computer. Any ideas on how to eject it?
-
Submit Button missing in Adobe Reader XI
Hi. I have designed an interactive PDF using Adobe LiveCycle. I have distributed the form and I am collecting responses through my adobe.com ID. This has worked perfectly well for my customers using Adobe Reader 8 - 10, however with Reader XI the "Su
-
To generate a flow chart of an organization, department wise.
Hi all, My requirement is to generate a flow chart which will show the organisation structure ( Heirachical positions of the employees ) . That means when I put department in the selection screen, the heirchical structure of all employees of that dep
-
Can i sync maps application on to my macbook? i would like to view
can anyone tell me if it is possible to sync "maps" with my macbook so i can save and view the dropped pins that i have created?