Javamail - no pop3 provider

Hello,
i have a problem with the javamail-1.3.1 API within the Oracle 9i (9.2.0.3) on Linux.
I would like to retrieve a POP3 account and process the incoming mails within a Java Stored Procedure.
I uploaded the javamail classes (imap.jar, mailapi.jar, pop3.jar, smtp.jar and the acivation.jar) into my account with the loadjava tool ( -resolve). When i try now to connect to a pop3 account, i get the error:
javax.mail.NoSuchProviderException: No provider for pop3
On the terminal my function works properly, so i list the available javamail providers and notice that on the oracle 9i the pop3 provider is missing.
my sourcecode fragment:
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
Provider[] providers = session.getProviders();
for (int z = 0; z < providers.length; z++)
System.out.println (providers[z]);
store = session.getStore("pop3"); // within the Oracle, i get here the above error
terminal - provider list:
javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc]
Oracle 9i - provider list:
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]
Where is my pop3 provider and how can register my pop3 mail provider within the oracle 9i ?
best regards
Adam Caban

Good job coming up with the workaround, verpixelt! I guess it seems that Apple's philosophy is to make it 'even that much easier' to setup an email account on the iphone in iOS5, however, my legacy email account is not IMAP, and yet it tried to create an IMAP account, which wreaked havoc on my ability to use my email account on my iphone. Your solution of setting up the account with the wrong password gave me the ability to make the IMAP/POP choice which then allowed my email account to function normally on my iPhone 4S. Thanks. 
Apple, - please put the IMAP/POP selection option back in for email account setup on the iPhone. Thank you.

Similar Messages

  • IMAP/POP3 provider for JMS

    I've searched through the net, but yet unsuccessfully. The question was: is there any IMAP/POP3 provider for JMS available? Or there are only MOM-oriented solutions?
    Thanks in advance!

    Check out SwiftMQ. It provides a JavaMail bridge for in/outbound bridges JMS/JavaMail and vice versa:
    http://www.swiftmq.com/products/extension/javamail/index.html
    -- Andreas

  • Set flags in a pop3 provider

    I am using a pop3 provider which doesn't support any permanent flags. But I want to know what are the new messages. How do I do it?

    I am using a pop3 provider which doesn't support any
    permanent flags. But I want to know what are the new
    messages. How do I do it?i don't think there is any flag in POP3
    personally, I would store the date of the last interrogation, and I would erase the messages after each interrogation (what is frequent whith POP).

  • Javamail + smtp/pop3 servers

    Hi,
    I run the demo in the javamail-1.2. it worked but there is no mail received.
    I think the problem is with my smtp server.
    my smtp was 1st smtp, the program runs but I have the message : invalid adresse receiver.(all addresses : yahoo, private...)
    I changed it to surgemail wich is pop3 and smtp serevr mail. I have no error message but I didn't receive any mail.
    how to solve this problem?
    thank you for your time.

    maybe you need to be using smtp-auth... there is an example with javamail.

  • Es1javax.mail.NoSuchProviderException: No provider for pop3 ?

    What is wrong with this code?Do i need to specify a Provider? Where and when?
    String host = ...;
    String username = ...;
    String password = ...;
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session ses = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = ses.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    Thank you all
    Dena

    [denapuerta],
    The exception that you are getting may mean that the java runtime environment that you are running your class file code on does not seem to have the JavaMail .jar files installed correctly. The JavaMail API packages are optional packages and must be downloaded and added to the J2SE runtime environment before such an application can run successfully.
    From the exception message, looks like either the pop3.jar file or the mailapi.jar (which contains all the JavaMail API and provider library files) is missing from the CLASSPATH of the JRE or not installed onto the <JRE install directory>/jre/lib/ext directory.
    What is wrong with this code?Do i need to specify a
    Provider? Where and when?I assume you obtained the code from the jGuru tutorial on JavaMail (which is a good tutorial to start off with). I have tested the code before and it works perfectly fine.
    String host = ...;
    String username = ...;
    String password = ...;
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session ses = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = ses.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " +
    + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    Thank you all
    Dena
    You might also want to check the username/password and hostname string entries to see if you are really connecting to the POP3 mail server correctly.
    HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Using MAPI with JavaMail

    I want to use MAPI protocol to send mail. Is it possible with java mail API.
    I would appreciate if some body can give me a solution.
    Thanks
    Saikumar

    There are only two JavaMail providers by Sun and are for POP3 and IMAP.
    For MAPI, there is no JavaMail provider, but JIntegra has a product called
    JESP-JavaMail Exchange Service Provider.
    This is JavaMail implementation and is like a provider.
    You can use this provider, which internally makes MAPI calls.

  • Using POP3, possible downloading mails without the attachment?

    Hello,
    I am constructing an email client, with limited system resources, using JavaMail and pop3. I can only download mails that are about 8kb. So if an email has a large attachment I can not download it. I am however still interested in what the textual body of the email says. I know that the header information can be downloaded without downloading the whole email but can the textual body be downloaded without downloading the attachment?

    Hi,
    As far as I know, you are unable to do this with the standard POP transport protocol since the attachement is actually a part of the body (encoded, multi-part), so there is no specific way for the server to know where the text body ends and the attachement body starts (most servers are mail content ignorant).
    I suppose you could try to intercept the incoming TCP data and cut the communication short the moment you intercept a part seperator (the attachements normaly are at the end of the message .. yet this is not guaranteed as far as the RFC is concerned).
    play around with:
    com.sun.mail.pop3.POP3Message.getContentStream()
    hope this helps a little.
    frgd,
    J.

  • Junk characters display while using multipart with html content in Javamail

    Hi All,
    I have used Java mail API to send mail with attachment. To enable to attachment in mail and to do content formatting i have used multipart and html content type together.
    My web application runs on apache tomcat 5.5 in MAC server. Java version is 1.5.
    The Function which i have used for sending mail with attachment is as follows:
    public void sendmailAttached(String to,String from,String host,boolean debug,String mailContent,String mailSubject,String cc,String attachFiles)
              String mailarray[]=to.split(";");
              Properties props = new Properties();
              //props.put("mail.smtp.port","425");
              props.setProperty("mail.smtp.host", host);
              if (debug) props.setProperty("mail.debug", ""+debug);
              Session session = Session.getInstance(props, null);
              session.setDebug(debug);
              try {
                   Message msg = new MimeMessage(session);
                  msg.setFrom(new InternetAddress(from));
                 javax.mail.internet.InternetAddress[] toAddress=new javax.mail.internet.InternetAddress[mailarray.length];
                 for (int i=0;i<mailarray.length ;i++ )
                                            toAddress=new javax.mail.internet.InternetAddress(mailarray[i]);
              msg.setRecipients(Message.RecipientType.TO, toAddress);
              msg.setSubject(mailSubject);
              try{
                        String ccaray =cc;                    
                        String mailarray1[]=ccaray.split(";");
                        javax.mail.internet.InternetAddress[] CCAddress=new javax.mail.internet.InternetAddress[mailarray1.length];
         for (int i=0;i<mailarray1.length ;i++ )
         CCAddress[i]=new javax.mail.internet.InternetAddress(mailarray1[i]);
              msg.setRecipients(Message.RecipientType.CC,CCAddress);
              }catch(Exception ss)
                        System.out.println("CC mail exception is ====>"+ ss.getMessage());     
              msg.setSentDate(new java.util.Date());
              Multipart multipart = new MimeMultipart("related");
              BodyPart messageBodyPart = new MimeBodyPart();
              messageBodyPart.setContent(mailContent, "text/html");
              multipart.addBodyPart(messageBodyPart);
                   String fileName = attachFiles.substring(attachFiles.lastIndexOf("/")+1,attachFiles.length());
                   if(!fileName.equals(""))
                        messageBodyPart = new MimeBodyPart();
              DataSource source = new FileDataSource(attachFiles);
              messageBodyPart.setDataHandler(new DataHandler(source));
              messageBodyPart.setFileName(fileName);
              multipart.addBodyPart(messageBodyPart);
              msg.setContent(multipart);
              Transport.send( msg );
              catch(MessagingException mex)
                   Exception ex = mex;
                   if (ex instanceof SendFailedException)
                   SendFailedException sfex = (SendFailedException)ex;
    Address[] invalid = sfex.getInvalidAddresses();
    if (invalid != null) {
    if (invalid != null) {
    for (int i = 0; i < invalid.length; i++)
    System.out.println("Invalid Addresss --------> " + invalid[i]);
    try
         Message msg = new MimeMessage(session);
              msg.setFrom(new InternetAddress(from));
              Multipart multipart = new MimeMultipart("related");
         BodyPart messageBodyPart = new MimeBodyPart();      
         messageBodyPart.setContent(mailContent, "text/html");
    multipart.addBodyPart(messageBodyPart);
    Address[] validUnsent = sfex.getValidUnsentAddresses();
    javax.mail.internet.InternetAddress[] toAddress=new javax.mail.internet.InternetAddress[validUnsent.length];                         
    if (validUnsent != null) {
    for (int i = 0; i < validUnsent.length; i++)
    System.out.println("Valid Address ------>"+validUnsent[i]);
    String test = validUnsent[i]+"";
    toAddress[i]=new javax.mail.internet.InternetAddress(test);
    msg.setRecipients(Message.RecipientType.TO, toAddress);
    msg.setSubject(mailSubject);
    String fileName = attachFiles.substring(attachFiles.lastIndexOf("/")+1,attachFiles.length());
                   if(!fileName.equals(""))
                        messageBodyPart = new MimeBodyPart();
              DataSource source = new FileDataSource(attachFiles);
              messageBodyPart.setDataHandler(new DataHandler(source));
              messageBodyPart.setFileName(fileName);
              multipart.addBodyPart(messageBodyPart);
    msg.setContent(multipart);
    Transport.send( msg );
    catch(Exception e)
         System.out.println("Mail Not Send");
              else
                        System.out.println("Mail Server Not Connectd ");
    This code is working properly and i am able to send mail with attachment and html formatted content without any problem. But console of server is filled up with too much junk characters because of which the catalina.out file of tomcat server is becoming fully filled.
    Sample cosnole display with  junk characters are as follows:
    Subject: HBSP - DRUCKER - QC - CH16 - QC  R2 Completed
    MIME-Version: 1.0
    Content-Type: multipart/related;
         boundary="----=_Part_34_15681668.1247471518887"
    ------=_Part_34_15681668.1247471518887
    Content-Type: text/html; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    <b>Hi,</b><br><br>     Chapter CH16 in the project DRUCKER is Completed . <br><br>     <b>Comments :</b> Qc Accepted.<br><br> <b><i>Thanks,<br>ANTONY.</i></b>
    ------=_Part_34_15681668.1247471518887
    Content-Type: application/octet-stream; name=9420317_CH06_p084-119.pdf.zip
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=9420317_CH06_p084-119.pdf.zip
    UEsDBBQAAAAIAMOz6TqHaQ4BUtXhAGzP8QAZAAAAOTQyMDMxN19DSDA2X3AwODQtMTE5LnBkZsQ7
    CTxUX9tCUpIWEomxpoWZuTN3FmvW7P9skaUajCXGiCHSYiuKFrIvlWStROSvaBEtiIpkK5WlUipa
    ZKl898wYRP/37fve7/e69TjnPuc5z3LOuc95zjP3ym7S1lXAKuL5ZTu7HjTyL8ATiCgMiu6wA6Wi
    gjZy86RSvN12U51QWLQRCguT8ESISED/hcITMWgdFJZIgPAwBm2CwhHQFqAdRySRcWg9lC2KBBNQ
    WAIRZ6+mxk/1dEI48qNYF7+/N9WZHwiCSPyY8QtLQDFLlCf/AhYGgiHyDBwBIs7EETEzcCR4Bg6H
    IZBn4LBE7AwcNBOHJ87EwWQ8aTqOgIWJM3C4mX2JMH6GLiQiHjMDR8bD03BYDBYizcDh8LjpOCyM
    xczAETH4mbgZOmNhmDCDHwE7Qz+IhMNO54eHCKTp/GAcboYuBBJMmi6DSIZxU+lYF7KSJnEMb4qb
    B9WbH1md5sjCROHJMHqTN9VvfPGRcGgzOp2BwhOQMUKZofU9nenIDYF1o22rgtXU1EWGRgsia2vp
    Like this display of junk characters are filling up multiple pages of console file.
    Can any one suggest me how to overcome this problem?
    Many thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There is no "sendmail" method in the JavaMail API.
    The debug flag is set using the Session.setDebug method, or by setting the Session property "mail.debug".
    If you're using someone else's helper classes with JavaMail, they may provide another way to set it.

  • How to identify  received mail is failure delivery notice mail in javamail?

    Hi friends,
    My requirement is that i have to identify failure delivery notice mails while receiving mails through javamail api pop3..
    Is there anyway to idenity those among normal mails?
    luking forward ur replies dudes...

    If you search this forum you'll find some examples, including a simple modification
    to the msgshow.java demo program to illustrate the basic use. And don't forget
    to read the javadocs for the com.sun.mail.dsn package.
    The basics are...
    Check for a message of type "multipart/report" (isMimeType), fetch the content of
    that message (getContent) and cast it to a MultipartReport object, then use the
    methods of that object to extract the data and process it however you want.

  • Pop3 message numbers

    Hi
    I am writing an email client using javamail and POP3 server. But the problem is if I delete any mail then the messages are reordered but when a new mail arrives it is given a message number in the middle .
    Can any one tell what exact algorithm is used for givimg the message number. Or any other way for tracking new messages.
    Any Help will be welcome.

    hi,
    Try this....... It will show you the listing of ur messages......
    =================================
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import com.sun.mail.pop3.* ;
    import com.sun.mail.imap.* ;
    public class SunMsgShow
    static String protocol =null ;
    static String host = null ;
    static String user = null;
    static String password = null;
    static String mbox = "INBOX";
    static int port = -1;
         public static void main(String s[])
              protocol = "pop3" ;
              host = "pop.mail.yahoo.com" ;
              user = "shahnazali_99" ;
              password = "ur Password here";
         try
                             Properties props = System.getProperties();
                             Session session = Session.getDefaultInstance(props, null);
                             session.setDebug(false );
                             // Get a Store object
                             Store store = null;
                                  if (protocol != null)
                                       store = session.getStore(protocol);
                                  else
                                       store = session.getStore();
                                  // Connect
                                  if (host != null || user != null || password != null)
                                       store.connect(host, port, user, password);
                                  else
                                       store.connect();
                             // Open the Folder
                             Folder folder = store.getDefaultFolder();
                             if (folder == null)
                                  System.exit(0) ;
                             folder = folder.getFolder(mbox);
                             if (folder == null)
                                  System.exit(0) ;
                             try
                                  folder.open(Folder.READ_WRITE);
                             catch (MessagingException ex)
                                  folder.open(Folder.READ_ONLY);
                                  // Attributes & Flags for all messages ..
                                  Message[] msgs = folder.getMessages();
                                  // Use a suitable FetchProfile
                                  FetchProfile fp = new FetchProfile();
                                  fp.add(FetchProfile.Item.ENVELOPE);
                                  folder.fetch(msgs, fp);
                                  for (int i = 0; i < msgs.length; i++)
                                       dumpMessageHeader(msgs);
                                       if (folder instanceof com.sun.mail.pop3.POP3Folder)
                                            com.sun.mail.pop3.POP3Folder pf = (com.sun.mail.pop3.POP3Folder)folder;
                                       String uid = pf.getUID(msgs[i]);
                                       if (uid != null)
                                                 System.out.println ( "UID:" + uid );
                                       else
                                            if (folder instanceof com.sun.mail.imap.IMAPFolder)
                                                 com.sun.mail.imap.IMAPFolder pf = (com.sun.mail.imap.IMAPFolder)folder;
                                                 long uid = pf.getUID(msgs[i]);
                                                 System.out.println ( "UID:" + uid );
                             folder.close(false);
                             store.close();
              catch (AuthenticationFailedException ex)
              catch (MessagingException ex)
    public static void dumpMessageHeader(Message m) throws MessagingException
                   Address[] a;
                   String from = "";
                   String subject ="";
              // FROM
                   if ((a = m.getFrom()) != null)
                   for (int j = 0; j < a.length; j++)
                             from = from + " " + a[j];
              // SUBJECT
                   subject = m.getSubject() ;
                   String aboutMessage = "From " + from + " Subject: " + subject ;
                   System.out.println ( aboutMessage);
    =================================
    Bye,
    Shaan

  • No idea about javamail

    i found a code using google to send a mail
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SmtpGmail {
       public static void main(String[] args) {
         SmtpSsl smtp = null;
         // gmail username - CHANGE THIS
         String username = "[email protected]";
         // gmail password - CHANGE THIS
         String password = "password";
         // address to send mail to - CHANGE THIS
         String to = "[email protected]";
         try {     
           // create a new SmtpSsl instance connecting securely via port 465 using implicit SSL
           smtp = new SmtpSsl("smtp.gmail.com",465);
           // establish secure connection
           smtp.connect();
           // login using gmail account details
           smtp.login(username,password);
           // create new email message
           EmailMessage message = new EmailMessage();
           message.setTo(to);
           message.setFrom(username);
           message.setSubject("Sending email via Gmail SMTP");
           message.setBody("This is the body of the message");
           // send message
           smtp.send(message);
           // disconnect     
           smtp.disconnect();     
         } catch(Exception e) {
           // capture any exception and print to console
           e.printStackTrace();
    SmtpGmail.java:9: cannot find symbol
    symbol  : class SmtpSsl
    location: class SmtpGmail
         SmtpSsl smtp = null;
         ^
    SmtpGmail.java:21: cannot find symbol
    symbol  : class SmtpSsl
    location: class SmtpGmail
           smtp = new SmtpSsl("smtp.gmail.com",465);
                      ^
    SmtpGmail.java:30: cannot find symbol
    symbol  : class EmailMessage
    location: class SmtpGmail
           EmailMessage message = new EmailMessage();
           ^
    SmtpGmail.java:30: cannot find symbol
    symbol  : class EmailMessage
    location: class SmtpGmail
           EmailMessage message = new EmailMessage();
                                      ^
    4 errorsthis error is shown....is it because i couldnt add properly in environment variable??
    my classpath of user variable looks like this
    .;C:\javamail\javamail\mail.jar;C:\javamail\jaf\activation.jar;C:\javamail\javamail\lib\dsn.jar;C:\javamail\javamail\lib\imap.jar;C:\javamail\javamail\lib\mailapi.jar;
    C:\javamail\javamail\lib\pop3.jar;C:\javamail\javamail\lib\smtp.jar

    I don't know what API you're using but it's not JavaMail.
    The JavaMail FAQ will show you how to connect to Gmail, and will point you
    to the source code of example programs you can use.

  • DELETE Flag

    Hi. I am having issues deleting mail on a pop3 server. I understand the expunge() method is not supported by the pop3 provider and neither are flags with the exception of DELETE.
    I have tried setting the delete flags as such:
    "folder.setFlags(msgs, new Flags(Flags.Flag.DELETED), true);"
    calling "folder.close(true);" should close the folder and delete the messages since the value of "expunge" is set to true.
    According to the JavaMail API this should work ... and it doesn't [for me].
    Any thoughts/suggestions? Thanks.

    I am retrieving e-mail from a gmail account. I do not receive any errors and .SetDebug is as follows:
    DEBUG: setDebug: JavaMail version 1.4ea
    DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.
    POP3Store,Sun Microsystems, Inc]
    DEBUG POP3: connecting to host "pop.gmail.com", port 995, isSSL false
    S: +OK Gpop ready for requests from *****
    C: USER *****
    S: +OK send PASS
    C: PASS *****
    S: +OK Welcome.
    C: STAT
    S: +OK 1 3364
    C: NOOP
    S: +OK
    C: TOP 1 0
    S: +OK message follows
    ***** message *****
    C: RETR 1
    S: +OK message follows
    ***** more message content *****
    C: DELE 1
    S: +OK marked for deletion
    C: QUIT
    S: +OK Farewell.
    Maybe the issue is gmail (because of its message archiving system)?
    Maybe the issue is permissions/type of connection? The standard port for POP3 is 110. I'm using 995 [for secure POP3] but the output above clearly says "isSSL false so who knows; that's another issue in itself.
    I'm rather stumped and confused! Thanks for your help!

  • Delete mail from server after receiving

    Hello,
    after I've received a message from the mail server I want to delete this message on the server. How can I realise this?
    Thanks JSCH

    Hi,
    This is from Sun tutorial.
    Go through this. :)
    Cheers.
    Deleting messages involves working with the Flags associated with the messages. There are different flags for different states, some system-defined and some user-defined. The predefined flags are defined in the inner class Flags.Flag and are listed below:
    Flags.Flag.ANSWERED
    Flags.Flag.DELETED
    Flags.Flag.DRAFT
    Flags.Flag.FLAGGED
    Flags.Flag.RECENT
    Flags.Flag.SEEN
    Flags.Flag.USER
    Just because a flag exists doesn't mean the flag is supported by all mail servers/providers. For instance, besides deleting messages, the POP protocol supports none of them. Checking for new mail is not a POP task but one built into mail clients. To find out what flags are supported, ask the folder with getPermanentFlags().
    To delete messages, you set the message's DELETED flag:
    message.setFlag(Flags.Flag.DELETED, true);
    Open up the folder in READ_WRITE mode first though:
    folder.open(Folder.READ_WRITE);
    Then, when you are done processing all messages, close the folder, passing in a true value to expunge the deleted messages.
    folder.close(true);
    There is an expunge() method of Folder that can be used to delete the messages. However, it doesn't work for Sun's POP3 provider. Other providers may or may not implement the capabilities. It will more than likely be implemented for IMAP providers. Because POP only supports single access to the mailbox, you have to close the folder to delete the messages with Sun's provider.
    To unset a flag, just pass false to the setFlag() method. To see if a flag is set, check with isSet().

  • Get SMTP reply code

    Hi,
    I am using destination mail server to send emails. For example to send an email to [email protected] , I do an MX lookup on mailservers for hotmail.com and use that to send mail to user fred. The reason for this is that
    I get better email validation. For example - if user fred does not exist then, I know it straight away as I get error 550.
    From what I can see, Javamail does not provide functionality to retreive SMTP reply code. It will be good if a method is added to Messaging Exception class that returns the SMTP reply code that caused the exception.
    From what I understand, the only method to get SMTP reply code is to parse the exception message for an int.
    Is there any alternative to get the SMTP reply code that caused the exception?
    Regards,
    Anmol

         public static int getSmtpErrorCode (Exception ex){
              String exceptionString = ex.toString();
              StringTokenizer tokens = new StringTokenizer(exceptionString);
              int code = 0;
              boolean flag = false;
              while(tokens.hasMoreTokens()){
                   if (flag == true) {
                        break;
                   try {
                        flag = true;
                        code = Integer.parseInt(tokens.nextToken());
                   } catch (Exception e){
                        flag = false;
              return code;
         }

  • Mail attachment in java

    hi
    Here is the code i am using for mail attachment without attachment it is working fine
    package com.nihon.login;
    import java.util.Properties;
    import java.util.ResourceBundle;
    import javax.activation.DataHandler;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;
    import javax.mail.BodyPart;
    import javax.mail.Message;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import javax.mail.util.ByteArrayDataSource;
    public class Mail {
    * @param args
    private static String host = null;
    private static String from = null;
    private static String to = null;
    private static String subject = null;
    private static String content = null;
    private static String filename = "D:\\Users
    entry.pdf";
    public static void send(String fromAddress,String toAddress,String subject, String mailContent) throws Exception{
    send(fromAddress,toAddress,null,subject,mailContent);
    public static void send(String fromAddress,String toAddress, String ccAddress,String subject, String mailContent) throws Exception {
    ResourceBundle rb = ResourceBundle.getBundle("com.nihon.login.Application");
    MailInfo mail = new MailInfo();
    mail.setMailServer(rb.getString("nihon.mail.server"));
    if(fromAddress!=null){
    mail.setFromAddress(fromAddress);
    }else{
    mail.setFromAddress(rb.getString("nihon.mail.fromID"));
    host = mail.getMailServer();
    // Get system properties
    Properties props = System.getProperties();
    // Setup mail server
    props.put("mail.smtp.host", host);
    // Get session
    Session session = Session.getDefaultInstance(props, null);
    // Define message
    MimeMessage message = new MimeMessage(session);
    // Set the from address
    message.setFrom(new InternetAddress(mail.getFromAddress()));
    // Set the to address
    if(toAddress!=null)
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
    if(ccAddress!=null){
    message.addRecipient(Message.RecipientType.CC, new InternetAddress(ccAddress));
    // Set the subject
    message.setSubject(subject);
    // Set the content
    message.setText(mailContent);
    For attachment
    BodyPart messageBodyPart = new MimeBodyPart();
    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(messageBodyPart);
    messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename);
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName(filename);
    multipart.addBodyPart(messageBodyPart);
    message.setContent(multipart);
    // Send message
    Transport.send(message);
    // Method to instantiate once
    public static Mail getInstance() {
    if (instance == null) {
    instance = new Mail();
    return new Mail();
    // Construtctor
    protected Mail() {
    private static Mail instance = null;
    But now i add some code for attachment after that i got the exception in below
    javax.mail.MessagingException: IOException while sending message;
    nested exception is:
    java.io.IOException: No content
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:625)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at com.nihon.login.Mail.send(Mail.java:104)
    at com.nihon.login.Mail.send(Mail.java:47)
    at com.nihon.login.Mailsender.sendMail(Mailsender.java:47)
    at com.nihon.login.Mailsender.attributeAdded(Mailsender.java:19)
    at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1334)
    at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1243)
    at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
    at com.nihon.track.OnsitePlacement.doProcessRequest(OnsitePlacement.java:347)
    at com.nihon.track.OnsitePlacement.doPost(OnsitePlacement.java:420)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Unknown Source)
    How can i solve this problem.
    Thanks in advance.......

    If the message is in an Exchange server, you can access it with JavaMail
    and extract the attachment. See the JavaMail FAQ and the many sample
    programs that come with JavaMail.
    If the message is in Outlook's message store on your desktop machine,
    it's harder. You need a JavaMail "message store provider" that understands
    the message store format used by Outlook on your local disk. JavaMail
    doesn't come with such a provider, but you might find one in the Third
    Party Products list on the JavaMail web page.

Maybe you are looking for

  • Custom Renderer

    Hi, I've created a custom parser which on taking certain binary files parses and inserts them into oracle tables. So anytime a file is updated on iFS so are the tables. Now conversly I want a custom renderer so whenever data is updated or inserted in

  • Can't Make a Hot Spot!

    Hi there, I'm using Dreamweaver 8 to make a new website. For some reason I can't make a hot spot. I've only made one website before and just checked on those pages and was able to click on the hot spot tools and draw a hot spot. Then I go to my new w

  • Key command for "Fit" video to Viewer?

    When the image in the viewer is enlarged I always use the "Fit" command to bring it back to the correct size. I can't find a keyboard shortcut for this  ...........  is there one?

  • Organizational Unit-BP

    Hi gurus. When i create a new organizational unit, i can't see the business partner asigned in the PPOMA_CRM. Why can it happen? Thanks Regards Miguel.

  • Mac locks up when trying to resize a smart object

    I'm building a poster with many layers using CS4 and an iMac and I keep running into 1 major problem. I want to resize one of the layers, so I converted it into a smart object and then hit commant-t to be able to resize it.  At this point my computer