Sending image in mail

Hi,
I have a requirement to send image in mail.
I got a code from a post which is as following :
import javax.mail.* ;
import javax.mail.internet.* ;
import java.util.Properties;
class SimpleMail1 {
    public static void main(String[] args) throws Exception{
        System.out.println("Sending mail...");
        Properties props = new Properties();
        props.setProperty("mail.transport.protocol", "smtp");
        props.setProperty("mail.host", "smtp.mymailserver.com");
        props.setProperty("mail.user", "myuser");
        props.setProperty("mail.password", "mypwd");
Session mailSession = Session.getDefaultInstance(props, null);
        mailSession.setDebug(true);
        Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
        message.setSubject("HTML  mail with images");
// write sender's and recpient's email address
   message.setContent
          (" img src=image_path" + "html/text");;    
        transport.connect();
        transport.sendMessage(message,
            message.getRecipients(Message.RecipientType.TO));
        transport.close();
Here, the image is being taken from an internet link whereas I am working on Linux server.
If I place a file on some location on the server, how to get the file from this location in this code?
Regards,
Nikhil

Cary,
I got your email overnight.
The 5 attachments are full size JPEG files, and the overall size of the message is 4.5 MB. Three of them have been compressed more than the other two, which you can see looking at the file sizes shown in the attached screenshot I sent back to you, but all of them decompress into full size photos of good size.
You may have muddied the water slightly, by Forwarding rather than sending a new message as you did originally. That can easily be checked if you open the message as originally sent, click on Message in the menubar and choose Send Again -- then change the To address to mine.
However, I think there is another issue causing the message to be sent in Rich Text Format, which causes some conversion of text to HTML, which then is problematic to some email clients some recipients use on Windows computers, notably Outlook and Outlook Express. Specifically, the file name of each photo appearing beneath and between each attachment can cause this, as could multiple fonts (but you did have that). To stop the file name printing, which is coming from iPhoto's preparation of the message, change the selection in the Email dialogue in iPhoto to deselect Include Title and Include Comments.
Then be sure to send all such messages in Plain Text, and be sure to use Windows Friendly if not already.
Ernie

Similar Messages

  • Sending Images from Mail to Aperture

    Hey all,
    I'm sure people have asked this, but I haven't found any satisfactory responses, so here we go again...
    I want a simple way to send images I receive via email to Aperture rather than iPhoto.
    How can I do this?
    Is it simple?
    If not, why haven't Apple sorted this out? Given even cameraphones are now snapping at 6 - 10 mpixels, images sent via email can no longer be considered 'amateur'.
    Thanks
    Sam

    Please ask Apple to add this feature. It's there for iPhoto, we'd like it for Aperture.
    http://www.apple.com/feedback/aperture.html
    Until then, use Frank's Automater action. It works great.

  • How to send image file through mail without   any attachment

    Plz tell  me how to send image file through mail without any attachment  ( i mean not converting  that image into pdf or any format )  i want to send that text or image  through mail .

    Hi Sandeep,
    I think you can setup the type of email in Shared office Settings in transaction S016.
    There is an option called <Preset document classes>
    You choose this pushbutton to branch to the maintenance screen for the document classes that are directly displayed to users in the Business Workplace for selection when they use the Create function. The name under which the documents are displayed can also be maintained.
    http://help.sap.com/saphelp_nw70/helpdata/en/6c/69c30f418d11d1896e0000e8322d00/content.htm
    Haven't tried it though.
    Regards,
    Siddhesh

  • 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.

  • How to send image as a part of body with java mail

    How to send image (.GIF) file in mail body & not as an attachement using java mail API

    You need to create a multipart/related message.
    You'll probably find examples in this forum.

  • Mail not sending images

    A friend uses Mail on OS X (not sure which version) and can't send images inline. She's tried copying the image then pasting it within the body of the email message, but when it is received it shows either a question mark or a broken image icon.
    I have tried the same on my Mac (OS 10.4.11) and it works fine. Is there a setting that she needs to have set on her system in order for the images to be sent?
    Thanks.

    Thanks for the reply, Ernie.
    From what she's told me, she is copying image files from her desktop or some folder and pasting them into her emails. She can see the image that she pasted, but the images are not being sent, just the text. She wants to embed the images as opposed to attaching them because some of her recipients don't like opening attachments.
    I have done as she described and was able to succesfully send and receive (I sent them to myself and opened the email in another reader) the emails.
    I had her check her preferences, and in the View section all selections were checked as they are in mine. Is there something else that should be selected within Mail to allow embedded images to be sent?
    Thanks again.
    Ted

  • When sending images via iPhoto it doesn't register as sent mail in A

    When sending images from iPhoto it does not register as sent mail in Apple Mail. Is there an option to allow this?

    No.  But in iPhoto's Info tray for that photo there will be a note that the photo was mailed and to whom:
    Click to view full size
    OT

  • Sample Java  Code to send an HTML mail with embeded image

    Hello,
    Please can I get a sample Java code on sending an HTML mail with embeded image.
    The HTML message and relevant input parameters withhbe supplied from a PL/SQL that will call the class , the class will embed the image and send the mail to the recepient.

    tev wrote:
    Please can I get a sample Java codeNo. This is a forum, not a code mill.
    Recommended reading: How to ask questions the smart way
    db

  • Can I send an E-Mail with photo (not as an attachment)?

    I would like to send an E-Mail with a small photo (not as an attachment) to someone who is reluctant to open attachments. Can I do this and how??
    Thank you
    tch

    If you insert an image into the body, it will still be 'attached', even though it won't be listed as an attachment in the usual way. Another option is to upload the photo to your personal storage space such as OneDrive or Google Drive, and then email the link to the image. The image can then be displayed in a web browser. If you don't have a storage space, there are plenty of free image-hosting services.

  • How do I reduce the "KB" size of a photo to better send on e mail?

    How do I reduce the "KB" size of a photo to better send on e mail?

    Where is the image?  What software are you using?  What software do you have?
    (If it is iPhoto or Aperture, you might get better answers in those forums:
    Aperture
    iPhoto

  • Is it possible to have Thunderbird send an e-mail automatically when a message with a specific subject is received?

    Is it possible to have Thunderbird send an e-mail automatically when a message with a specific subject is received?
    I basically want to create a rule that will send an automatically crafted form e-mail to the sender when I receive an e-mail with the subject line "New Swimmer". Is this possible?

    Thank you Todd, I was able to get it to work but I do have a few more questions...
    1) When I tested this, at the top of the message, before any of the text I created, this showed up: This is a multi-part message in MIME format. --------------040406040801080102080500 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
    2) After the signature line, this showed up: --------------040406040801080102080500 Content-Type: image/jpeg Content-Transfer-Encoding: base64 Content-ID: /9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAA AAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0K CgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwM DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAC5ApUDASIAAhEBAxEB/8QA HwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQID AAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6 Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/
    (It was actually much longer than that)
    Is there anyway that I can get that to go away? I obviously would prefer a nice, cleanly formatted e-mail to be sent just like I would send if I were creating it on the spot.
    Thanks,
    Evan

  • How do I send images in an email, but not embedded in the message body?

    I want to submit some jpg images of artwork to a competition and the rules state that attached images must *not* be embedded in the email body. They want the list where you can see the file name and you click on it to open it, as I've seen in Windows MS Outlook. I've searched the net and I see that this is a problem for other people, but I've not seen a solution.
    I'm using the current version of iMail, and I've tried setting the message to Plain Text, the "Windows Friendly" setting, as well as the "Always attach at end of message" setting. All leave the image embedded. I'm using the current version of iMail. Anyone know how to do this? I have a deadline approacing so time is of the essence. Thanks!!

    I agree that it's a shame to have to buy something that I feel Mail should already do. That said, it seems that people's experience with sending attachments using Mail seems varies - I believe it's often to do with how the recipients email client is configured.
    All I know is that since installing Attachment Tamer (used to be called Mail Attachments Iconizer) a few years ago it's something I no longer have to bother about.
    I think you can run AT in demo mode to test flight it, before committing to buy.

  • How to send images using SOAP adapter

    hi All,
    I want to send images using the SOAP adapter . ( Sender and Receiver )
    Can anybody help out with this requirement
    Regards,
    Loveena

    Hi,
    Following links may help U
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/frameset.htm
    to know the basics about soap adapter u cn check out this link
    /people/padmankumar.sahoo/blog/2005/02/15/an-overview-of-soap
    to get in detail about the attachments chk out this link
    hi i am unable to attach an attachment in File to mail scenario
    Regards
    Pullarao

  • How to send birthday wish mail to Employees on daily basis

    Hi ,
    How to send birthday wish mail to employee with greeting card as background image in Mail Content area.
    Is there any Standard program available in SAP.
    _Requirement:_
        Normal , Birthday Wish mail can be done through function module SO_NEW_DOCUMENT_SEND_API1.
        How to write program for getting , Greeting card as background image in Mail Content area.
        Is there solution in SAP .
    Regards
      Surendar

    Hi,
    Check this for embedding image in your email : Using CL_BCS to send email from ABAP
    And this about image as background and other related stuff : http://www.reachcustomersonline.com/2010/01/23/09.27.00/#faqs
    Best regards,
    Guillaume

  • Unable to send images in Email

    Hi,
         I am trying to send site logo image in Email whenever a Email action is performed.
    My email template jsp is as :-
    <img src='<%=getServletContext().getRealPath("/images/e-commerce_header_img1.jpg")%>' />
    <dsp:importbean bean="/atg/userprofiling/Profile"/>
    <p>Dear <dsp:valueof bean="Profile.firstName"/>
    <p>Thank you for Registering with us.
    <p>Your Login Id is  : <dsp:valueof param="login"></dsp:valueof><br>
       Your Password is : <dsp:valueof param="password"></dsp:valueof>
       <a href='<%=getServletContext().getRealPath("/registration.jsp") %>'></a>
    </p>
    <p>Sincerely,
    The Customer Service Team
    [email protected]
    But the <img src=' '/> and the <a herf=' '/> is not displayed in the Email.
    My debug log is showing the appropriate path of the image and the hyperlink.
    Debug Log:-
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <img src='D:\MyApp\jboss-5.1.0.GA\server\atg_production\deploy\Storefront.ear\storefront-web.war\images\e-commerce_header_img1.jpg' />
    <p>Dear <username>
    <p>Thank you for Registering with us.
    <p>Your Login Id is  : <userID><br>
       Your Password is : **********
       <a href='D:\MyApp\jboss-5.1.0.GA\server\atg_production\deploy\Storefront.ear\storefront-web.war\registration.jsp'></a>
    </p>
    <p>Sincerely,
    The Customer Service Team
    [email protected]
    </body>
    </html>
    ------=_Part_4_7060822.1386214829362--
    09:10:31,781 INFO  [STDOUT] 250 OK id=1VoPnm-4gfN7a-5y
    09:10:31,783 INFO  [TemplateEmailSender] DEBUG email sent to Profile[4150003] ([email protected])
    09:10:31,783 INFO  [STDOUT] NOOP
    09:10:31,997 INFO  [STDOUT] 250 OK
    09:10:31,997 INFO  [STDOUT] QUIT
    09:10:32,212 INFO  [STDOUT] 221 smtpcorp.com closing connection
    What can the problem..?

    <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.

Maybe you are looking for