Sending a Rich Text (RTF) email using the Java Mail API

Folks
I've spent about half a day trying to find out how to do this, now I'm not even convinced you can. Here's the problem...
I currently use JasperReports to generate an HTML report, this I then send as the body of a Multipart email. Because there are two images in the report, these I inline attach, it diaplsy in Outlook perfectly.
The problem comes with a bug in Outlook (recognised by Microsoft) where after a while the images stop displaying, you just get the little red cross. Having dug around this is because Outlook doesn't always clean the inlined files from the temp directory. When this occurs next time you view an email that has the same image file in it, the file in the temp directory is appended with a number. This happens correctly until 99, then it throws the towel in and just gives you the red cross. Although I could orgainse for the folder to be emptied on network, I can't on client networks. Thsi sadly means that this approach isn't going to work for me.
My latest idea is to get JasperReports to generate an RTF version instead, then set this as the body of the email. I don't know if this will still require me to inline the images, if it does it's no better, but because I can't find a working example on how to send an RTF bodied email I can't even find out.
Any help anyone can provide is greatly appreciated.
Tom

I'm afraid neither of these are really feasible. The email is sent to many external parties, and guaranteed access to a server is unlikely to happen. I guess I could change the file name, but then I'd have to parse the HTML everytime and change the many reference to the file in there.
Why is information about sending RTF email so scarce? I assume it possible?
Tom

Similar Messages

  • How to use the java native api

    i am new to the java native api, can anyone tell me how to use it in order for me to use the c++ file in the java file?please explain it if possible, thanks

    Try this out to learn the basics :
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    You can't go wrong from there.

  • Do you use the e-mail APIs in Oracle 9iFS?

    Have you built an application that uses the Oracle 9iFS e-mail
    APIs?
    * oracle.ifs.adk.user package classes?
    * oracle.ifs.adk.mail package classes?
    * EmailUserProfile?
    If so, we would like to learn more about your requirements.
    Please contact me at [email protected]

    You cannot secure just the mail app other than to go into the Mail settings and remove the password there, a process you would have to repeat every time you wanted to access the email and were then done. Setting a screen lock passcode is, as Ed indicated, the way to protect your information on your iPad in case of loss or theft. If you use the long password rather than the simple (four digit) code, cracking into your iPad to access your data and accounts would be quite difficult for even an experienced thief.
    Regards.

  • Error while sending mail when using Java Mail API

    Hi Experts,
    I am trying to execute a webdynpro application which uses the Java Mail API to send emails. The exception that I get on executing the application is :
    Sending failed;  nested exception is: javax.mail.SendFailedException: Invalid Addresses;  nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
    Can anybody please help me sort out the issue.
    Regards
    Abdullah

    Hi,
    Usually one get this error if the SMTP server is configured not to relay mails (a security measure) or the SMTP server need the mail to be sent from a trusted IP or with proper authentication. Some SMTP servers are configured to block junk mails.
    Pls check with your  mail server administrator.
    Regards

  • Java.lang.UnsupportedClassVersionError while using java mail api

    Hi Everybody ,
    I am new comer to this forum , and would like to be an active member.
    I am getting this error while trying to use the java mail api to send an email using smtp.
    The error is as follows :
    Exception in thread "main" java.lang.UnsupportedClassVersionError: javax/mail/Message (Unsupported major.minor version 48.0)
    Can Anyone please tell where I am wrong.
    I am using the following code
    ==============================================================
    Properties props = new Properties();
    props.put("mail.smtp.host", "smtp.abc.com");
    // create some properties and get the default Session
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(debug);
    // create a message
    Message msg = new MimeMessage(session);
    // set the from and to address
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);
    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++)
    addressTo[i] = new InternetAddress(recipients);
    msg.setRecipients(Message.RecipientType.TO, addressTo);
    // Optional : You can also set your custom headers in the Email if you Want
    msg.addHeader("MyHeaderName", "myHeaderValue");
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
    ==============================================================

    Hi Philip ,
    Thanks for the prompt reply , I had installed oracle client services which overid my jdk1.4 installation with jdk1.3 and hence the error. I changed my classpath settings to point to jdk1.4 and it owrked properly.
    Thanks once again.
    regards,
    Rupesh Rajan

  • Problem using Java Mail API with WLS 7.0

    Hi All,
    I am trying to use the Java Mail API provided by WLS 7.0. I have made the
    settings metioned in the WLS 7.0 docs. However when I try to run the program I
    am getting the following error:
    javax.naming.NoInitialContextException: Need to specify class name in environment
    or system property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    46)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:283)
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    The code that I have written is as follows
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
         public static void main(String args[])
              try
                   //Context ic = getInitialContext();
                   InitialContext ic = new InitialContext();
    /* My jndi name is "testSession" */
                   Session session = (Session) ic.lookup("testSession"); /* THE PROBLEM IS SHOWN
    IN THIS LINE */
                   Properties props = new Properties();
                   props.put("mail.transport.protocol", "smtp");
                   props.put("mail.smtp.host", "XX.XX.XX.XX");
    /* For security reasons I have written the ip add in this format */
                   props.put("mail.from", "[email protected]"); /* for security reasons i have
    changed the mail address */
                   Session session2 = session.getInstance(props);
                   Message msg = new MimeMessage(session2);
                   msg.setFrom();
                   msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]",
    false));
                   msg.setSubject("Test Message");
                   msg.setSentDate(new Date());
                   MimeBodyPart mbp = new MimeBodyPart();
                   mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
                   Multipart mp = new MimeMultipart();
                   mp.addBodyPart(mbp);
                   msg.setContent(mp);
                   Transport.send(msg);
              catch(Exception e)
                   e.printStackTrace();
         }//end of main
    public static Context getInitialContext()
         throws NamingException
              Properties p = new Properties();
              p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
              p.put(Context.PROVIDER_URL, "t3://localhost:7501/testWebApp");
                   p.put(Context.SECURITY_PRINCIPAL, "weblogic");
                   p.put(Context.SECURITY_CREDENTIALS, "weblogic");
              return new InitialContext(p);
    }//end of class
    Can anyone please tell me what is the problem. I thought that we cannot directly
    do
    InitialContext ic = new InitialContext();
    So I had written a method getInitialContext() as shown in the above piece of code,
    but that too did not work.
    Eagerly awaiting a response.
    Jimmy Shah

    You can use InitialContext ic = new InitialContext() only if you are using a startup class, servlet or a JSP i.e
    server side code.
    If you are using a java client you need to use Context ic = getInitialContext();
    Try this code
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
    public static void main(String args[])
    try {
    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL, "t3://localhost:7001");
    Context ic = new InitialContext(h);
    Session session = (Session) ic.lookup("testSession");
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", "XX.XX.XX.XX");
    props.put("mail.from", "[email protected]");
    Session session2 = session.getInstance(props);
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse("[email protected]",false));
    msg.setSubject("Test Message");
    msg.setSentDate(new Date());
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    Transport.send(msg);
    catch(Exception e)
    e.printStackTrace();
    }//end of main
    }//end of class
    We have shipped a javamail example in the samples\server\src\examples\javamail folder.
    Jimmy Shah wrote:
    Hi All,
    I am trying to use the Java Mail API provided by WLS 7.0. I have made the
    settings metioned in the WLS 7.0 docs. However when I try to run the program I
    am getting the following error:
    javax.naming.NoInitialContextException: Need to specify class name in environment
    or system property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    46)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:283)
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    The code that I have written is as follows
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
    public static void main(String args[])
    try
    //Context ic = getInitialContext();
    InitialContext ic = new InitialContext();
    /* My jndi name is "testSession" */
    Session session = (Session) ic.lookup("testSession"); /* THE PROBLEM IS SHOWN
    IN THIS LINE */
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", "XX.XX.XX.XX");
    /* For security reasons I have written the ip add in this format */
    props.put("mail.from", "[email protected]"); /* for security reasons i have
    changed the mail address */
    Session session2 = session.getInstance(props);
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]",
    false));
    msg.setSubject("Test Message");
    msg.setSentDate(new Date());
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    Transport.send(msg);
    catch(Exception e)
    e.printStackTrace();
    }//end of main
    public static Context getInitialContext()
    throws NamingException
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, "t3://localhost:7501/testWebApp");
    p.put(Context.SECURITY_PRINCIPAL, "weblogic");
    p.put(Context.SECURITY_CREDENTIALS, "weblogic");
    return new InitialContext(p);
    }//end of class
    Can anyone please tell me what is the problem. I thought that we cannot directly
    do
    InitialContext ic = new InitialContext();
    So I had written a method getInitialContext() as shown in the above piece of code,
    but that too did not work.
    Eagerly awaiting a response.
    Jimmy Shah--
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support

  • Using Java Mail API from Tomcat

    Hello,
    Purely as an academic exercise I have written a JSP page which, upon being requested from the client's browser, should send me a default email using Java Mail Api.
    here is the code :
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class TestMail {
        static String msgText1 = "success this time 12";
        static String msgText2 = "This is the text in the message attachment.";
        public String sendIt() {
            String to = "<my email";
            String from = "<anything>";
            String host = "<my ip address of smtp server>";
            boolean debug = false;
            Properties props = new Properties();
            props.put("mail.smtp.host", host);
            Session session = Session.getInstance(props, null);
    .....The code works fine as a stand alone app but when called from JSP page it hangs on the Session.getInstance line. I can only guess that this might be a security issue with the container not allowing access to the smtp server ?
    Can anyone give me a clue ???

    Your Tomcat log files should spell out the problem for you.
    My Tomcat installation does not come with the Java Mail API. I had to add the mail and activation jar files to the server/common.lib directory (or the server's shared/lib or the WEB-INF/lib of your application.)
    HTH.

  • Newbie question on the Java communications API

    Hi All,
    I found the javax.comm extension package that lets me listen to the serial port of the PC, but am unsure as to how to use it. Well, I've tried running the SimpleRead.java program and I get an error message that says the package is missing in the import (which I assume means that I havent downloaded it and added it to one of the folders in my Java directory). Where can I find the package from? And am I missing anything else?
    In case you're all wondering, I've got a microcontroller attached to the serial port that sends data periodically. I would like to use the Java comm API to read the incoming data (and if possible store it in the form of a text file or something). Any suggestions would be great as I'm still new to Java. More of a C/C++ person (^_^) Thanks in advance.....

    Did you try using that little search field in the upper right hand corner of your browser?

  • How to do SAVE AS DRAFT using java mail api

    Hello,
    I want to know how to do SAVE AS DRAFT using Java mail Api.
    thanks

    Hello,
    I want to know how to do SAVE AS DRAFT using Java
    mail Api.
    thanksI don't think you can. That sounds like a feature of a mail client app itself. The Java mail API is for when you're ready to actually send the thing. Saving drafts is storing them somewhere like you would any other data; nothing to do with the mail API.

  • Can anyone help me to find the Java Speech API?

    I really need to use the Java Speech API but I don't have any idea where to find it.
    In the Sun page are many implementations of the API but I want to use it and is very important for me.
    Please, can anyone send me the little API...........

    Look at the thread two posts down, that might be what youre looking for. Theres also a thread seven posts down that will help you.

  • How to maintain format in html email using the send email....

    Does anyone know how to maintain the format in a HTML email using the Send E-mail To Recipients From Recordset behavior?
    When text only is selected instead of HTML text on the Options tab the format of the input is maintained, but when HTML text is selected the email has no format. I have tried to use a replace \n with
    as I have done when hand coding PHP, BUT I am trying to learn to use ADDT. I also tried to use a Custom trigger without success.
    Help!

    Hi Dave,
    in my snippets folder I have this thing which I found on the old MX Kollection forums and which was suggested by the Interakt staff:
    //trigger SendEmail (write content)
    function Trigger_SendEmail(&$tNG) {
    ob_start();
    include("myDynamicContentFile.php");
    $mailcontent = ob_get_contents();
    ob_end_clean();
    $emailObj = new tNG_Email($tNG);
    $emailObj->setTo("[email protected]");
    $emailObj->setFrom("[email protected]");
    $emailObj->setSubject("A new User was added");
    $emailObj->setContent($mailcontent);
    $emailObj->setEncoding("UTF-8");
    $emailObj->setFormat("text");
    $emailObj->setImportance("Low");
    return $emailObj->Execute();
    //trigger SendEmail (write content)
    The only modification is the possibility to include a dynamic PHP file rather than some static text or a HTML file which will also render textarea contents on one line:
    ob_start();
    include("myDynamicContentFile.php");
    $mailcontent = ob_get_contents();
    ob_end_clean();
    That said, it should be possible to define all the "rendering" options in the external PHP file, what would mean to apply the nl2br function there, e.g.: nl2br($row_queryname['columnname'])
    What I´m not sue about is, if you will have to strip the external file´s head and body tags before it´s getting included -- however, please give this a try and tell us how it worked.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Sending an email using the gmail client on the iPhone

    Hello,
    When I send an email using the gmail client on the iPhone, the message I send then shows up in my 'in box' and not my 'sent' box. Mail app on my computer behaves in the same manner. Is there a fix for this?
    Thanks for your help.

    Hi, its because gmail treats each message as a "conversation" rather than emails sent or recieved. so your sent email will say "from me" all in the same inbox. check this on the web based gmail...

  • How Do I Increase The Speed Of Sending Emails Using The Mail Service on my Mac Mini Server?

    Note: This is the first time I have set up a mail server.
    I have a Ruby on Rails application where I am currently sending approx. 240 individual emails with the potential of more being sent each week as more people add themselves to our mailing list.  I am sending them invidually in order to personalize the emails and to hopefully prevent my emails being falsely identified as spam.
    The GoDaddy email address I was using in my Rails application has a daily limit of sending 250 emails each day.  With our mailing list fastly approaching 250 I decided to set up an email address on my Mac Mini Server using Mountain Lion (OS X Server).  The email address was set up to be stored locally at the advice of Apple Enterprise Support.  This email address will not be used in an email program.  It will only be used in all my Rails applications.
    My emails send properly but take almost 10 seconds an email.  When I use the same software with GoDaddy's email address the emails take about eight minutes to send.  With the email address I created it takes about 41 minutes.  The difference seems to have to do with the sacl_check being done.  Here is an example of what I see for each email in mail.log.
    Mar 14 11:06:50 hostname.domain1.com postfix/qmgr[45322]: 4B2C5603D25: removed
    Mar 14 11:06:59 hostname.domain1.com postfix/smtpd[99464]: sacl_check: mbr_user_name_to_uuid([email protected]) failed: No such file or directory
    There is 9-10 seconds that elapses when the sacl_check.  If I subtract this difference the remaining time is almost the time that the GoDaddy email takes to send the same number of emails.
    The link below is a post about the sacl_check.  I was looking at the comments by powercore from Germany at the comments where settings in /etc/postfix/main.cf are discussed.
    https://discussions.apple.com/thread/3241121?start=0&tstart=0
    Will making these setting changes speed up the sending of the emails from my Mail Server or is there something else I can check?

    http://en.wikipedia.org/wiki/Intel_Quick_Sync_Video
    OS X [edit]
    Apple added Quick Sync support in OS X Mountain Lion for AirPlay Mirroring and QuickTime X.[9]

  • HT5622 .mac mail - I still use my .mac email address to access itunes, icloud, etc. Every once in a while, apple sends me confirmation, reservation, etc. emails to the .mac address. Can someone tell me how to access that email account?

    .mac mail - I still use my .mac email address to access itunes, icloud, etc. Every once in a while, apple sends me confirmation, reservation, etc. emails to the .mac address. Can someone tell me how to access that email account?

    Hi pjerl,
    Depending on when you originally set up your Apple ID, you may have @mac.com, @me.com, and @icloud.com email addresses associated with your account, but all mail sent to those addresses should still come in to the same iCloud account (you can test this to make sure by sending yourself emails at those addresses). You may find the following articles helpful:
    iCloud: About your @icloud.com, @me.com, and @mac.com email addresses
    iCloud: Using your @icloud.com email address
    Regards,
    - Brenden

  • I used to be able to send document as a PDF or Word Document via email using the toolbar.

    I used to be able to send Pages documents as a PDF or Word Document via email using the Pages toolbar (not the iWork feature).  Lately, it hasn't been working at all.  No email pops up; just nothing.  Is anyone else having this problem?  Any solutions?  I'm running Pages '09 version 4.1.

    This Apple Express Helper is a dumb one.
    File names with # and $ are perfectly treated by the share to Mail feature.
    What is rejected is the slash (/) and it's perfectly normal.
    Since the delivery of the first version of OS X, slash is an illegal character in file names.
    Apple thought that it would be fair to build a piece of code taking care of such chars because they were valid ones in the older operating systems.
    But they expected that users will drop these chars. Alas they didn't and users like you are continuing to play with matches.
    At last, OS X 10.7 removed the extraneous code and now, hosanna, iWork refuse to export files whose name contain the infamous slash.
    Yvan KOENIG (VALLAURIS, France) lundi 9 avril 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

Maybe you are looking for

  • Pages '08 30-day Trial

    Hi all, I installed a Pages '08 30-day trial copy one week ago and today I was greeted with the message that my trial period is over (already!). Has this happened to anybody else and does anyone know how to try to fix the trial copy? Thanks a lot, Gu

  • PO creation via BAPI is not into database after run BAPI_PO_CREATION1

    Dear friends , I have done an case to test PO creation via BAPI_PO_CREATION1. I run the BAPI and the PO number is presented to me. But the PO is not in the database. Should I done another step to write this PO into the database? best regards, Ale

  • I need to shrink down my iPhoto Library

    I need to shrink down my iPhoto Library - I'm currently working with iPhoto 09' on my supervisor's iMac running Mac OS X 10.6.8 (Snow Leopard). He's in desparate attempt to try and free space on his hard drive. Through Finder iPhoto reads over 340+ G

  • Fire fox locks up and is real slow when using windows 7 64bit

    I am using windows 7, 64bit when you click on a "go to link" phrase/word the program either locks up or takes a real long time to to go to the link site. program loads real slow (it take 3 to 4 times longer than in windows xp. I am using fire fox 4.0

  • Update in back ground indicator "VERSION COMPLETED"

    Hi, All. How can I change for PO in back ground indicator "version completedu201D to u201Cxu201D. for PO version 0? I know  that  in customizing  I can do it  for plant . In my case I need to do it only for some purchase groups in the plant and for s