Problem in sending images

Hi All,
I have a problem in sending HTML mail with images.I am able to get the image in my mail if i place the image part and the html part in two different tables I am able to get the image along with the html message but if i use the following code i.e using single table i am not able to get the image someone plase help me to get this done and tell me where am i going wrong?
Properties props = System.getProperties();
                props.put("mail.smtp.host", smtpServer);
                Session session = Session.getDefaultInstance(props, null);
                 Message message = new MimeMessage(session);
               message.setFrom(new InternetAddress(from));
                message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
                 message.setSubject(subject);
               message.setSentDate(new Date());
                MimeBodyPart messageBodyPart = new MimeBodyPart();
          MimeBodyPart messageBodyPart1 = new MimeBodyPart();
          MimeBodyPart messageBodyPart2 = new MimeBodyPart();
StringBuffer msgStrBuf = new StringBuffer();
msgStrBuf.append("<html><head></head> <body><table  width=\"640\" align=\"center\"  height=\"293\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#D3D3D3\" ><tr><td><img src=\"cid1:image1\" width=\"640\" height=\"92\"></td></tr>");
DataSource fds1 = new FileDataSource("webimages\\sampleimage.jpg");
messageBodyPart.setDataHandler(new DataHandler(fds1));
messageBodyPart.setHeader("Content-ID1","<image1>");
String headerbody = "";
msgStrBuf.delete(0,msgStrBuf.length());
msgStrBuf.append("<tr><td width=\"640\" align=\"center\"   bgcolor=\"#E6E6E6\" height=\"50\" valign=\"top\"><font size=\"2\" color=\"#4C4C4C\" face=\" Arial,Verdana, Helvetica, sans-serif\">����Dear "+locUserName+","+"<br><br>����"+"Here is the updated status report on your project.</font></td></tr>"+"  <tr> <td bgcolor=\"#E6E6E6\" height=\"100\" align=\"center\" valign=\"middle\">  <table width=\"95%\" height=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"4C4C4C\" >" +"<tr> <td width=\"200\" align=\"left\" valign=\"middle\"><strong><font  size=\"2\" face=\" Arial,Verdana, Helvetica, sans-serif\" color=\"#FFFFFF\">��PROJECT:</font></strong></td><td><font  size=\"2\" face=\" Arial,Verdana, Helvetica, sans-serif\" color=\"#FFFFFF\"><strong>"+getProjectName+"</strong></font></td></tr>"+"   <tr> <td  width=\"200\" align=\"left\" valign=\"middle\"><font  size=\"2\" face=\" Arial,Verdana, Helvetica, sans-serif\" color=\"#FFFFFF\"><strong>��LAST UPDATE:</strong></font></td><td><font  size=\"2\" face=\" Arial,Verdana, Helvetica, sans-serif\" color=\"#FFFFFF\"><strong>"+concatTime+"</strong></font></td></tr></tr></table></td></tr> "  );
msgStrBuf.append("<tr> <td  bgcolor=\"#E6E6E6\" height=\"50\" valign=\"middle\"><font size=\"2\" color=\"#4C4C4C\" face=\" Arial,Verdana, Helvetica, sans-serif\">����" +"In case you have any questions, please send an email to <a href=\"mailto: </a>. Our customer <br>����service representative will contact you to address any  concerns. ");
msgStrBuf.append("<br><br>����Thank You,<br> ���.</font></td></tr>");
msgStrBuf.append("<tr><td  bgcolor=\"#E6E6E6\" height=\"100\" valign=\"top\"> <br><hr><font color=\"#666666\" size=\"-6\" face=\" Arial,Verdana, Helvetica, sans-serif\">����This is an automatically generated email. Please do not reply to this. If you need further information, contact the email address <br>����given above.<br>����If you wish to change your contact email address, please log in to follow the link and modify your<br>����preferences. You can also change the frequency of email updates in the project settings link.</font></td></tr>");
msgStrBuf.append("</table></body></html>");
headerbody = msgStrBuf.toString();
messageBodyPart1.setContent(headerbody,"text/html");
// Part two is attachment
String mailingFileId = "";
if(locGroupClass.equals("2"))
mailingFileId = "XL Data/"+getProjectID+".xls";
else{
mailingFileId = "GPXL Data/"+getProjectName+".xls";
System.out.println("mailingFileId :"+mailingFileId);
System.out.println("locGroupClass :"+locGroupClass);
String mailingFileNAme = getProjectName+".xls";
DataSource source = new FileDataSource(mailingFileId);
messageBodyPart2.setDataHandler(new DataHandler(source));
messageBodyPart2.setFileName( mailingFileNAme);
multipart.addBodyPart(messageBodyPart);
multipart.addBodyPart(messageBodyPart1);
multipart.addBodyPart(messageBodyPart2);
// Put parts in message
          message.setContent(multipart);
                   Transport.send(message);
                System.out.println("Message sent OK.");
              } catch (Exception ex)
                          ex.printStackTrace();
                    }Message was edited by:
rameshr

messageBodyPart.setHeader("Content-ID1","<image1>");The name of the header is "Content-ID", not "Content-ID1".
Of course, if you used the setContentID method on MimeBodyPart,
the compiler would find this error for you.

Similar Messages

  • Problem in sending images in Email

    Hi,
         I am unable to send images in Email.
    My template jsp is as :-
    <img src='<%=getServletContext().getRealPath("/images/logo.jpg")'%>
    In Email its not displaying .
    Please help..
    Thanks

    <img src='<%=getServletContext().getRealPath("/images/logo.jpg")'%>
    Above code is not displaying image coz when browser is rendering email content, It's expecting logo.jps to be present in image directory relative to browser temporary folder, Which is not..
    If u wan to display image in mail, U have two options:
    Either attach image in mail as suggested by Prateek.
    Make Image url a absolute url.
    Usually Sites send email with absolute ur, When u read email, ur browser gets the image and render the content along with image.
    Thanks,
    Nitin.

  • Problem in Sending image in Email Notification

    Hi All,
    In our implementation we have to send customer logo in each email notification.
    We have SIM 7.1 deployed on SUN JES Application server 8.2.
    I tried to send the image using two ways but nothing got succeed.
    1) Using <IMG src"http<machine name>:<port number>/idm/images/<image name>"/>
    2) Deployed another trial.war file having only image folder and then using <IMG src"http<machine name>:<port number>/trial/images/<image name>"/>
    Where "machine name", "port number" and "image name" have suggestive values as per our environment.
    But i am not able to send the image. however second options works well with Tomcat.
    If anybody has any prior experience or some idea please share. it will really be helpful for us.

    Hi all,
    Its done.
    Actually there is some issue related with the intranet (may be they are blocking the image to get diaplayed) as its working for gmail and all.
    Thanks

  • Problem in sending image from applet to servlet

    dear friends,
    i have a need to send an image from applet to servlet via HttpConnection and getting back that image from applet.
    i am struggling with this sice many hours and got tired by searching any post that would help me but haven't got yet.
    i tried using this code but it dosent make any execution sit right. i got NPE at ImageIcon.getDescription() line;
    at applet side
          jf.setContentPane(getJContentPane());
                     FileDialog fd=new FileDialog(jf,"hi");
                     fd.setMode(FileDialog.LOAD);
                     fd.setVisible(true);   
                     v=new Vector();
                     try{                                                
                               FileInputStream fis=new FileInputStream(new File(fd.getDirectory()+fd.getFile()));      
                               byte[] imgbuffer=new byte[fis.available()];
                               fis.read(imgbuffer);
                               ImageIcon imgdata=new ImageIcon(imgbuffer);
                               v.add(0,imgicon);
                                String strwp ="/UASProject/Storeimage";              
                                URL servletURL = new URL(getCodeBase(),strwp);             
                                HttpURLConnection servletCon = (HttpURLConnection)servletURL.openConnection();       
                                servletCon.setDoInput(true); 
                                servletCon.setDoOutput(true);
                                servletCon.setUseCaches(false);
                                servletCon.setDefaultUseCaches(false);   
                                servletCon.setRequestMethod("POST");     
                                servletCon.setRequestProperty("Content-Type", "application/octet-stream");   
                                servletCon.connect();            
                                ObjectOutputStream oboutStream = new ObjectOutputStream(servletCon.getOutputStream());                     
                                oboutStream.writeObject(v);
                                v.remove(0);
                                oboutStream.flush();      
                                oboutStream.close();  
                                //read back from servlet
                                ObjectInputStream inputStream = new ObjectInputStream(servletCon.getInputStream());
                                 v= (Vector)inputStream.readObject();                     
                                 imgicon=(ImageIcon)v.get(1);
                                 showimg.setIcon(imgicon);
                                 this.getContentPane().validate();
                                 this.validate();  
                                inputStream.close();                                                        
                             //  repaint();
                     }catch(Exception e){e.printStackTrace();}  and this is at servlet side
            try {       
                         Vector v=new Vector();                    
                         ObjectInputStream inputFromjsp = new ObjectInputStream(request.getInputStream());                                      
                          v = (Vector)inputFromjsp.readObject();                                                                                                          
                          imgicon=(ImageIcon)v.get(0);                     
                          inputFromjsp.close();            
                          System.out.println(imgicon.getDescription());                                      
                          v.remove(0);
                          v.add(1,imgicon);
    //sending back to applet
                           response.setContentType("application/octet-stream");
                          ObjectOutputStream oboutstream=new ObjectOutputStream(response.getOutputStream());            
                          oboutstream.writeObject(v);
                          oboutstream.flush();
                          oboutstream.close();
                   } catch (Exception e) {e.printStackTrace();}  i really need your help. please let me out of this headche
    thanks
    Edited by: san_4u on Nov 24, 2007 1:00 PM

    BalusC wrote:
    san_4u wrote:
    how can i made a HttpClient PostMethod using java applets? as i have experience making request using HttpURLConnection.POST method. ok first of all i am going make a search of this only after i will tell. please be onlineOnce again, see link [3] in my first reply of your former topic.
    yeah! i got the related topic at http://www.theserverside.com/tt/articles/article.tss?l=HttpClient_FileUpload. please look it, i am reading it right now and expecting to be reliable for me.
    well what i got, when request made by html code(stated above) then all the form fields and file data mixed as binary data and available in HttpServletRequest.getinputstream. and at servlet side we have to use a mutipart parser of DiskFileItemFactory class that automatically parse the file data and return a FileItem object cotaing the actual file data,right?.You can also setup the MultipartFilter in your environment and don't >care about it further. Uploaded files will be available as request attributes in the servlet.is the multipartfilter class file available in jar files(that u suggested to add in yours article) so that i can use it directly? one more thing the import org.apache.commons.httpclient package is not available in these jar files, so where can got it from?
    one mere question..
    i looked somewhere that when we request for a file from webserver using web browser then there is a server that process our request and after retrieving that file from database it sends back as response.
    now i confused that, wheather these webservers are like apache tomcat, IBM's webspher etc those processes these request or there is a unique server that always turned on and process all the request?
    because, suppose in an orgnisation made it's website using its own server then, in fact, all the time it will not turned on its server or yes it will? and a user can make a search for kind of information about this orgnisation at any time.
    hopes, you will have understand my quary, then please let me know the actual process
    thanks
    Edited by: san_4u on Nov 25, 2007 11:25 AM

  • Some recipients receive my images attached to emails, some find they are embedded and difficult to impossible to separate. Just found out that if I remove my attached signature, the problem goes away. How to send images   signature reliably?

    Some recipients receive my images attached to emails, some find they are embedded and difficult to impossible to separate. Just found out that if I remove my attached signature, the problem goes away. How to send images plus signature reliably?

    When you attach things, make sure to check the box that says [√] Send Windows-Friendly attachments

  • Until recently I was able to send images in the body of my Yahoo emails. Now, I am getting the message "This message has been truncated", and the email does not go through. I do not have this problem using IE. Could you please help? Thank you.

    Until recently I was able to send images in the body of my Yahoo emails. Now, I am getting the message "This message has been truncated", and the email does not go through. I do not have this problem using IE. Could you please help? Thank you.

    Try this -> http://support.apple.com/kb/TA38632?viewlocale=en_US

  • IMessage problem sending images on Wi-Fi

    Hi,
    A couple of weeks ago, after many years working without a glitch, I started experiencing sporadic erros when sending images on iMessage when connected to my home wifi. The problem seems to occurr with our iPhones but not with our iPads, however because the sporadic nature of the problem we just might have not experienced it yet. Nevertheless it happens so often with our iPhones and we've never seen it happen on one f our iPads.
    The charaterization of the problem is I try to send an image on iMessage, the progress bar hangs very near the end for an unusually long time, and eventually I get a red exclaim sign with the word Failure next to it. If I switch to 3G (which ***** because it consumes my dataplan), it works fine. I have a DSL ISP and 2 Airport Extremes networked thru a gigabit cable and configured as a Closed (non broadcasting SSID) Roaming Network.
    Corrective actions taken so far. I reset one of the iPhones back to factory settings. I've turned off the DSL Modem and both Airports, waited 30 seconds, and then turn everything back on.
    Any ideas?
    Thank You,
    Erasmo.

    I have exactly the same problem, I have been search for solution for many month already, so far Apple haven't give any solution to this problem. Still need wait for answer.

  • Have been trying all weekend to upload Jpegs- either Send does not work or shows files uploading then shows error- never had this problem with Send Now-16 images total size 92MB-largest image 13MB

    Have been trying all weekend to upload Jpegs- either Send does not work or shows files uploading then shows error- never had this problem with Send Now-16 images total size 92MB-largest image 13MB

    Hi Ciaran19,
    Are you sending files from the Adobe Send interface, Adobe Reader, or the Outlook plug-in?
    Have you checked to see whether the files that you're sending appear in the Recent Files/Sent Files list when you're logged on to https://cloud.acrobat.com? (It could be that they're uploading, but not being sent.)
    It would also be worthwhile to send the files in smaller batches, to see whether a particular file or files is problematic, and causing the error.
    Please let us know how it goes. If you're still having trouble, please let us know where you're sending from, and whether you're able to send the files in smaller batches. It would also be helpful to know the exact error message that you're receiving.
    Best,
    Sara

  • Problems sending images...

    I have a Nokia 7370, and am yet to suss out how to actually send images via MMS. I have followed the book, and tried this site for specifics on my model, and I end up with the same message each time - Media settings not defined...
    Can anyone help? Where am I going wrong?

    What network are you on?
    You should be able to get the correct settings from the
    Nokia Site and from your networks.
    Try getting them again from both and see what happens - make sure the correct ones are activated.
    Nokia History: 3110, 5110, 7110, 7110, 3510i, 6210, 6310i, 5210, 6100, 6610, 7250, 7250i, 6650, 6230, 6230i, 6260, N70, N70, 5300, N95, N95, E71, E72
    Android History: HTC Desire, SE Xperia Arc, HTC Sensation, Sensation XE, One X+, Google Nexus 5

  • Mail and iPhoto Problems with sending photos.

    Mail and iPhoto Problems with sending photos.
    I have this problem that started a while ago and seems to be getting worse.
    Here are the different scenarios.
    -If I try to share a photo to email within iPhoto, it will insert the image file name in the mail message, but no image icon or opened image. In iPhoto Preferences under General I have chosen to use Email Photos using Mail.
    -If I choose to use iPhoto to send the photo, it will compose the message and the photo is viewable. If I send the message i can view the photo within the email I sent to myself. Nothing happens when I double click on the photo in the Mail message. Nothing happens when i control click on the photo in the mail message. Nothing happens when I try to drag the photo to the desktop from the mail message. When I try to save attachments from the email and choose a place to save it, the save button is grayed out and it cannot be saved. When I check the mail message it says there is an attachemnt but there is no file size listed.
    -If I use the stationary within Mail app I cannot drag a photo into the placeholder, I get a circle with a line through it symbol when I try. It happens if I try to drag a photo from the desktop or from the media browser within Mail app.
    -If I drag the photo to the desktop from iPhoto, I can double click it on the desktop and it will open in Preview.
    -If I then control click on the same photo on the desktop and scroll to share/email, the generic photo icon will be inserted in the mail message. If i double click the photo icon in the mail message  I get a message it can't be opened because it is empty.
    -If I drag that same image to the mail message body the same thing happens.
    -If I send that email to someone they cannot open the image file.
    What I can do:
    - I can drag that same image file on the desktop to my dropbox folder and  it will upload. From there I can go on my iPad and download the photo and send it through email just fine.
    -I can open the same image file on my desktop in Preview, I can copy and paste it into a mail message and the image will be viewable in the mail message by me and by the recipient.
    -I can drag that same image on the desktop to my safari browser window and it will be viewable in the page. i can then copy and paste that image into a mail message and it is viewable in the message.  I can then send that email message to myself and i can control click on the image and get all my options. It also shows as an attachment with the size of the image file in the mail message.
    I can send that message to someone and they can see the photo and open it fine.
    -If I send that same email to me I can see the photo within the mail.  If I then drag that photo to the desktop I cannot use it again to put in an email as the same problem happens again.
    I have tried all scenarios in my user account, another users account and in a guest account. The same happens in all. I am guessing because of this it is not a corrupt preference file, unless all of the preference files are corrupt. The guest user account I added a new email account so it was brand new and still had the problem.
    I am stumped, all and any help is appreciated.

    Another problem that may be related….
    I have Snapz Pro. I used to be able to save the snaps to my desktop or a folder. Now when I take a screenshot and try to save the file to my desktop or a folder on my desktop I get this message  "Files cannot be created in the selected location. You do not have permission to write to the selected location.   Please choose a different location."  I have found that i can only save the file to the clipboard.   I have repaired permissions many times and still I have this problem.

  • When I send image attachments through Mail they are received as very small and squashed. How can I change this?

    I have a problem sending image attachements (e.g., jpeg, png files etc) with the Mail utility from my MacBook Pro.  When people receive my email the attached image shows up not as an attached file that can be saved or downloaded, but as just a very small, squashed up version of the image imbedded in the email message itself.
    I usually add these attachments by simply dragging and dropping the desired file into the window of the email text. Is this the wrong way to do it?
    thanks
    Jerry

    Is this the wrong way to do it?
    The safest way to send images is to create a compressed file and send that.
    Click the image you want to send, go to File in the menu bar and select Compress... You end up with a file with a .zip at the end. Attach that to your email. Then trash the .zip file.
    The person at the other end only has to double click the .zip attachment.
    You can compress are single image or a folder of them.

  • Unable to SEND images in BBM and What's App

    I am unable to send images in BB Messanger and What's App. The SEND oprion does not appear when i try to forward an image to bbm contact. In What's App it shows 'Upload Failed'. Apprears to be some common setting problem on the Blackberry. Any ideas of how to resolve

    Could you explain how you're going about to send an image via BBM?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Sending Image ( stored in SAP )  to Email

    Hi All,
    I have to Send image stored in SAP ( OAER or SE78 ) to Body of email. I am able to send image stored in net to email .please help me in this regard.
    Thanks,
    Ananth

    Hi,
    You can download SE78 images to user computer and then you can email it.To download the image from se78 you can go through this sdn disscussion [Re: download image from se78 to desktop...|Re: download image from se78 to desktop...]
    Hope this can solve your problem.
    With best regards,
    Pulak.

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • "Rend Error" when sending image via iChat/AIM

    On my brand new iMac aluminum, I am unable to send, and friends are unable to send, images via iChat AIM 3.1.8 (V445). When either of us try to send, we get the message "An undefined AIM error has occured. The server message was: Rend: Error"
    I then spin around and use my old G4 iMac to send an image - no problem. My buddy is also able to send to me, no problem.
    Both computers are connected to the same Linksys WRT54G router. When I searched for the term 'rend' only one thread came back which suggested to change the port from 5190 to 443. I did this and it didn't help.
    Any other suggestions?

    Hi Craig,
    In the Linksys set up pages you have Application and Gaming (Which is where I think you are talking about)
    In there there are several options.
    Port Forwarding, Port Triggering, DMZ (possibly UPnP Forwarding and QoS)
    Disable any Port Forwarding or Port Triggering. DO not use the DMZ.
    Save settings. (you should still have Web browsing and Mail abilities).
    GO to the Administration tab on the top row.
    Enable UPnP.
    Save Settings.
    UPnP allows multiple computers to use the same ports.
    This way the Linksys can be left doing DHCP if you wish and it will not matter if your computer gets a new IP every now and then. Also the Ports are opened by the application and close after a timed period of non use.
    You can limit the "Hops" to the number of devices the computer is from the Linksys (1 ?) to make it more secure.
    On the main set up page you could limit the the DHCP range to the number of computers you have to prevent outside connections.
    The ports you describe so far are only the TExt chatting and file sending ports
    11:23 AM Monday; August 13, 2007

Maybe you are looking for

  • Error running Execution plan for 'Project Analytics in PeopleSoft 9.0 '

    Hi , I am running execution plan for Projects Peoplesoft 9.0 (BI Apps version 7.9.6) The issue is the file type data source went thru the database (data warehouse) the tasks that were completed SUCCESS were from the File source only from (SrcFiles).

  • Unicode and Java

    Hi As we all know Java treat character literals as Unicode characters. I have been studying Unicode and the way they treat characters and I have a doubt which is not specific to Java code but specific to Unicode. Unicode states that each character is

  • Crystal reports 2008: Data appears upon refresh, but not on initial open

    I have an updated crystalreports.com / salesforce.com report to which I added a new subreport and an additional grouping.  The report is working fine, with one (rather major) issue: when the report is first opened, only some of the data is shown - th

  • Anyone familiar with TotalCode for Premiere?

    Anyone familiar with TotalCode for Premiere? http://www.rovicorp.com/products/distribution/content-production-tools/totalcode-for-adobe -premiere-pro.htm#overview

  • 1.5.1 - Having worksheeet remember its size

    Hallo Forum, I wonder if I can make the worksheet remember 1/3 SQL window and 2/3 result grid size. Whenever I open a new SQL Developer and a new worksheet, I get a large SQL window and the result grid is shrinked to a minimum. Do I miss something or