Mailbox migration using JavaMail

Has anyone ever attempted, successfully or otherwise, using the JavaMail API to write a program performing mailbox migration.
Essentially, the task of grabbing all the folders and msgs from one mailbox and putting them into another mailbox.
Thanks!
jrmy

See http://www.jservlet.com/
Use EMail object with Pop3 object (see method EMail.sendRedirect and use IMAP protocol for grabbing all folders)
regards,

Similar Messages

  • How to use Javamail for accessing additional mailboxes -IMAP, Exchange 2010

    hi,
    I want to access a shared mailbox (NOT FOLDER) via Javamail API (1.4.5) using IMAP(s) with plain logon. The mailserver is a Exchange Server 2010.
    User: user1 ([email protected])
    pwd: xxxx
    shared mailbox: [email protected]
    Properties:
    mail.imaps.socketFactory.port = 993
    mail.imaps.starttls.enable = true
    mail.imaps.socketFactory.class = javax.net.ssl.SSLSocketFactory
    mail.imaps.socketFactory.fallback = false
    username = [email protected]
    password = xxxx
    I´ve managed to get access to the user1 - mailbox:
    Session session = Session.getInstance(properties, new ExchangeAuthenticator(username, password));
    session.setDebug(true);
    Store store = session.getStore("imaps");
    store.connect(imapHost, username, password);
    --> this works just fine! But now i want to access the additional mailbox by changing the login-String:
    [email protected]/shared_MB (user@domain/additional_MB)
    --> unfortunately I´m getting an "NO AUTHENTICATE" message:
    DEBUG: setDebug: JavaMail version 1.4.5
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: mail.imap.statuscachetimeout: 1000
    DEBUG: mail.imap.appendbuffersize: -1
    DEBUG: mail.imap.minidletime: 10
    DEBUG: trying to connect to host "host.domain.com", port 993, isSSL true
    * OK The Microsoft Exchange IMAP4 service is ready.
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
    A0 OK CAPABILITY completed.
    DEBUG IMAP: AUTH: NTLM
    DEBUG IMAP: AUTH: GSSAPI
    DEBUG IMAP: AUTH: PLAIN
    DEBUG: protocolConnect login, host=host.domain.com, [email protected]/shared_MB, password=<non-null>
    DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed
    DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO AUTHENTICATE failed.
    javax.mail.AuthenticationFailedException: AUTHENTICATE failed.
    I was able to get access with Thunderbird and also with the Exchange OWA-Client, so I think there is something missing in my code...
    or is it just impossible to get access to a different mailbox using javamail and plain-auth?
    Thank you in advance.

    Thanks bshannon, that was a great idea!
    I haven´t found an solution yet, but I have maybe identified the real problem:
    Here is some interessting Thunderbird - Logging stuff:
    744[7161040]: try to log in
    744[7161040]: IMAP auth: server caps 0x1187235, pref 0x1006, failed 0x0, avail caps 0x1004
    744[7161040]: (GSSAPI = 0x1000000, CRAM = 0x20000, NTLM = 0x100000, MSN = 0x200000, PLAIN = 0x1000, LOGIN = 0x2, old-style IMAP login = 0x4)auth external IMAP login = 0x20000000
    744[7161040]: trying auth method 0x1000
    744[7161040]: got new password
    744[7161040]: IMAP: trying auth method 0x1000
    744[7161040]: PLAIN auth
    744[7161040]: 7082000:xmail.domain.com:NA:SendData: 2 authenticate plain
    744[7161040]: ReadNextLine [stream=7ec9e88 nb=3 needmore=0]
    744[7161040]: 7082000:xmail.domain.com:NA:CreateNewLineFromSocket: +
    744[7161040]: 7082000:xmail.domain.com:NA:SendData: Logging suppressed for this command (it probably contained authentication information)
    744[7161040]: ReadNextLine [stream=7ec9e88 nb=27 needmore=0]
    744[7161040]: 7082000:xmail.domain.com:NA:CreateNewLineFromSocket: 2 NO AUTHENTICATE failed.
    744[7161040]: authlogin failed
    744[7161040]: marking auth method 0x1000 failed
    ---> okay, so PLAIN AUTH is failing.....
    744[7161040]: IMAP auth: server caps 0x1187235, pref 0x1006, failed 0x1000, avail caps 0x4
    744[7161040]: (GSSAPI = 0x1000000, CRAM = 0x20000, NTLM = 0x100000, MSN = 0x200000, PLAIN = 0x1000, LOGIN = 0x2, old-style IMAP login = 0x4)auth external IMAP login = 0x20000000
    744[7161040]: trying auth method 0x4
    744[7161040]: got new password
    744[7161040]: IMAP: trying auth method 0x4
    744[7161040]: old-style auth
    744[7161040]: 7082000:xmail.xmail.domain.com:NA:SendData: Logging suppressed for this command (it probably contained authentication information)
    744[7161040]: ReadNextLine [stream=7ec9e88 nb=23 needmore=0]
    744[7161040]: 7082000:xmail.domain.com:NA:CreateNewLineFromSocket: 4 OK LOGIN completed.
    744[7161040]: login succeeded
    --> okay, so Thunderbird is using "old-style IMAP login" and is successful.
    Unfortunately I have no idea what that actually means or how to use it in Javamail (is it even supported?). Any suggestions?

  • Gettting attachments using JAVAMAIL

    Hi,
    I am dealing with an application which wants me to go through the mailbox and get the attachments of specific emails. These attachments are of different kinds. The attachments can vary from being rtf document, to Word, html, fo.. documents.. I got this skeleton code from the tutorial but dont know what to fill in..
    if (disposition == null) {
    // Check if plain
    MimeBodyPart mbp = (MimeBodyPart)part;
    if (mbp.isMimeType("text/plain")) {
    // Handle plain
    } else {
    // Special non-attachment cases here of
    // image/gif, text/html, ...
    What is it meant by handling plain? How do i handle html, worf, rtf documents.. Thanks a lot in advance.. Thanks
    Abhishek

    Try this as a reference. It works PERFECTLY. Ignore the comments.
    //If the content is ATTACHMENT
    filename = part.getFileName();
    if (filename != null) {
    filename = filename.trim();
    if(filename.equalsIgnoreCase(fileNameDownload.trim())) {
                                            //System.out.println("Downloading DOWN 1");
                                            session_id = this.DL_sessionid;
                                            directory = ATTACHMENTPath + m_user + "_" + session_id + "/";
                                            if(download) {
                                                 pushFile(part.getFileName(),part.getInputStream(),resp);
                                            } else {
                                                 saveFile(part.getFileName(), directory, part.getInputStream(), resp);
                                       filectr++;
         private void saveFile(String fileName, String Directory, InputStream input, HttpServletResponse resp)
              String myfile="";
              try
                   //Correct the file name;
                   String p_filename = javaFileParser(fileName);
                   File newDir = new File(Directory);
                   //Check if the directory does not exists!
                   if(!newDir.exists()) { //If it doesn't..
                        //Create the directory
                        newDir.mkdir();
                   String complete_path = Directory + p_filename;
                   File myFile=new File(complete_path);
                   //Check if a filename like this already exists!
                   if(myFile.exists()) {
                        //If it does..
                        //delete the current file residing into the directory
                        myFile.delete();
                   //Write the file (START)
                   FileOutputStream fos = new FileOutputStream(myFile);
                   BufferedOutputStream bos = new BufferedOutputStream(fos);
                   BufferedInputStream bis = new BufferedInputStream(input);
                   int aByte;
                   while ((aByte = bis.read()) != -1)
                   bos.write(aByte);
                   bos.flush();
                   bos.close();
                   bis.close();
                   //(END)
              catch (Exception x)
                   System.out.println("Error : " + x);
         private void pushFile(String fileName,InputStream input, HttpServletResponse resp)
              try
                   //Download the file to the Client's machine
                   ServletOutputStream stream = resp.getOutputStream();
                   resp.setContentType("application/octet-stream");
                   resp.setHeader("Content-Disposition","attachment;filename="+fileName.trim()+";");
                   //BufferedInputStream fif = new BufferedInputStream(new FileInputStream(complete_path));
                   BufferedInputStream fif = new BufferedInputStream(input);
                   int data;
                   while((data = fif.read()) != -1)
                   stream.write(data);
                   stream.flush();
                   fif.close();
                   stream.close();
              catch (Exception x)
                   System.out.println("Error : " + x);
         private String javaFileParser(String filename)
              //System.out.println("In EmailObject javaFileParser");
              String n_filename="";
              //Check if the file starts with '=?iso8859'
              //If it does, it will need parsing
              if(filename.startsWith("=?iso")) {
                   n_filename = filename.substring(15,filename.lastIndexOf("?"));
              } else
                   n_filename = filename;
              return n_filename;
    I suggest don't use JavaMail.. It has BUGS on some other email type. If not in POP3 then in IMAP.. Specialy when it receives "Enriched" contents types. Better yet don't use Java. It has lots of Bugs.

  • Mailboxes migration to new partition

    Dear Folks,
    We had to migrate the mailboxes from one partition to another, (partition 1 got full). We mounted another disk from SAN (600 GB) the double the size of existing partition (300 GB). How ever after the migration (mailboxes migration from old partition to new) , some how the partition size expanded, old partition was 290 GB and now after migrating the mailboxes to the newly mounted disk, partition size is 380 GB......Here is the question, How we can (OR keep the mailboxes compression) compress the mailboxes to keep the size of partition as it was in old partition (disk) ...???
    We are running :
    Sun Java(tm) System Messaging Server 6.2-4.03 (built Sep 22 2005)
    libimta.so 6.2-4.03 (built 04:37:42, Sep 22 2005)
    SunOS msgbak1 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-V490
    Many Thanks

    Sp00ky_Geek wrote:
    We had to migrate the mailboxes from one partition to another, (partition 1 got full). We mounted another disk from SAN (600 GB) the double the size of existing partition (300 GB). How ever after the migration (mailboxes migration from old partition to new) , some how the partition size expanded, old partition was 290 GB and now after migrating the mailboxes to the newly mounted disk, partition size is 380 GB......How did you move the emails from the old->new partition (single user mboxutil -r / copy/rsync the files across?).
    Here is the question, How we can (OR keep the mailboxes compression) compress the mailboxes to keep the size of partition as it was in old partition (disk) ...???
    If the expansion has occurred due to single-message copy being expanded by the move, you can use the relinker utility to reset the hard-links between identical messages.
    The theory behind single-message copy and the relinker utility are described here:
    http://docs.sun.com/app/docs/doc/819-2650/6n4u4dttt?a=view#bgaye
    Sun Java(tm) System Messaging Server 6.2-4.03 (built Sep 22 2005)
    libimta.so 6.2-4.03 (built 04:37:42, Sep 22 2005)
    SunOS msgbak1 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-V490I recommend patching to 118207-63 before using the relinker utility to fix bug #6496709 - "relinker should doublecheck"
    Regards,
    Shane.

  • Slow Mailbox Migration

    Hello All 
    We are in coexistence with 2007 and exchange 2013 and everything is working fine except mailbox migration, which is taking very long. 
    Mailbox size is average 200MB and migration for 10 mailboxes takes about 12 hours, even within the same LAN and across WAN link
    The architecture is
    DataCenter 1
    2007 Environment
    2013 CAS1
    2013 Mailbox1
    2013 Edge
    DataCenter 2
    2013 CAS2
    2013 Mailbox2
    2013 Edge2
    Has anyone experienced problems like this before?
    Thanks

    Hi,
    If the servers are performing other higher priority jobs, the mailbox movements will be stalled. When the servers get freed up from higher priority jobs, the mailbox movement resumes.
    I recommend you use the New-MoveRequest cmdlet with the Priority parameter to check the result.
    If only some mailboxes are affected, you can set the BadItemLimit parameter to a higher value to check the result.
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

  • PST Migration using PST Capture tool 2.0

    Hello,
    I am planning to use Microsoft PST Capture 2.0 tool to import PST's located on C: Drive of users to personal archive mailbox of the respective user in the on-premises exchange 2010 mailbox.
    There are total of 16000 users. I am wondering will PST Capture Tool, be able to handle this huge requirement? Based on past experience, can anyone suggest me healthy practice of planning PST migration using PST capture 2.0?
    Any help on this will be highly appreciated.
    Thanks in advance.
    Kapil

    Make sure you spec the PST Migration server properly, also, the number of PST files is not the problem, It's the size of all the PST files.
    From my experience keep an eye on the disk space because If you are using a DAG once you start the migration the DB log files will be massive and you will need to run full backup to clear them so make sure you run backups every 12 hours to clear the logs.
    If you batch them each night to a reasonable number your environment can handle everything should be fine.
    Cheers
    Exchange Blog:
    www.ntweekly.com
    MCSA, MCSE, MCITP:SA, MCITP:EA, MCITP:Enterprise Messaging Administrator 2010,MCTS:Virtualization

  • Mailbox migration from one server (country 1) to another server (country 2 ) ( exchange 2007)

    Hi,
    My exchange servers are hosted with my hosting service provider at London, i have 1000 users and each are having 3 Gig mail box size (exchange 2007) and this exchange server is part of our company network which is extended to hosting service provider. I
    need to setup new exchange 2007 as part of existing exchange organisation and migrate the users from London to Singapore.
    The bandwidth between our company and hosting facility 20 MB.
    What is the best method to move the mailboxes from loon service provide to our company ?
    I cannot do complete 3 gig mailbox migration from source to destination due to wan bandwidth limitation and time.
    I can do only move the mails to local pst then migrate the mailboxes to new server and import the pst mails to exchange mailbox.
    Is there any other method available ? backup and restoration ?
    Please help me to provide best method for mailbox migration.

    For migrating exchange mailboxes from one server to another server (across the country), the suitable approach will be to export mailboxes into pst files.
    This job can be simplified even more, take the offline copy of edb file to the destination system (at Singapore) then export all mailboxes (of all sizes) from offline file to separate PST files. Then run PowerShell scripts to import the PSTs. For extracting
    mailboxes from offline edb file use a stable edb converter solution that extracts mailboxes (even very large sized) & create new pst file for each of equivalent size.
    product overview: http://www.pcvita.com/edb-converter.html

  • Double Contacts Folder after Mailbox Migration

    Here’s a new one for you… I’ve done a few Exchange 2007/2010 to 2013 migrations so far, and to my knowledge they’ve been successful… until now…
    I migrated my own server from 2007 to 2013 over the weekend.  Mailbox migration finished early Tuesday morning my time (Monday was a public holiday).  Everything seemed to work just fine.
    Yesterday (Tuesday) I noticed on my Win8.1 phone, that a large number of my contacts were missing.  Digging deeper I found that my phone was missing the contacts from my main mailbox.  I checked my iPad to see if the contacts were there – they
    were!  I figured somethings up with my Win8.1 phone, so I removed the account and readded it – same problem.  I added a user to the contacts on my Win8.1 phone and sync’d it.  It showed up in the iPad no problems. 
    I then went to Outlook and switched the pane to Folder View – I could then see two contacts folder both at the root of my mailbox.  The test user was in the first folder.  If I try to expand the 2<sup>nd</sup> folder, it sends outlook
    into a massive loop and flickers between the two folders as if they are fighting one on one…
    If however I switch the view to People – I see the two contacts folders as just fine and can look into each of them.  In one of them I can see the Testuser.  In the other folder I can see all my other contacts that are "missing"
    But wait… it gets better still.  In our office several months back, we migrated from Exchange 2010 to 2013.  I wondered if others had seen the problem.  From what I can see today, it appears that anyone with a Windows 8 phone has this duplicated
    contacts folder. They appear to have the exact same problem… right down to the flickering and crash of Outlook 2013…
    I'm concerned now because this is now a couple of migrations that we've seen this on and I've no idea whats gone wrong.
    I've checked event logs - nothing seems amiss there.
    Any thoughts on how to troubleshoot this?
    Wayne
    Wayne Small

    Hi Wayne,
    I have seen this issue if original mailbox was in different language than the new mailbox.I have even seen this even if original mailbox had EN-US and new database is EN-UK.
    Please run the following command in Exchange powershell:
    Get-MailboxFolderStatistics [email protected] | Select Name,FolderSize,ItemsinFolder
    Do you see two contact folder here aswell?
    Solution for us it to copy all "old Contacts" to new Contact and delete the old one.When try to delete the default Contact you will get error message that it cant be removed.
    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work

  • Mailbox Migration Error

    I am operating an Exchange 2013 CU7 in a co-exit environment with an Exchange 2010 server. when I try to setup a mailbox migration through the EAC I receive and Error "Multiple potential Migration mailboxes were found for this organization. Please
    specify a particular Partition mailbox to use." and I can go any further or finish performing the migration.
    any thoughts would be appreciated.

    I contacted Microsoft to work through this error message and we were able to get it resolved.
    hear is the solution for this error message.
    within "Active Directory Users and Computer" in the
    Users OU, find and delete the following accounts. (don't worry we will recreate them in a few moments.)
    DiscoverySearchMailbox {D919BA05-46A6-415f-80AD-7E09334BB852}
    FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042
    Migration.8f3e7716-2011-43e4-96b1-aba62d229136
    SystemMailbox{1f05a927-0acd-45d5-9bc1-1a123e6fc52e}
    SystemMailbox{bb558c35-97f1-4cb9-8ff7-d53741dc928c}
    SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}
    Once they are removed, go to your Exchange 2013 server and run the following command from an elevated command prompt
    (locate the Exchange Setup File from you CD or download location and run)
    Setup.exe /Preparead /IAcceptExchangeServerLicenseTerms (this recreates all the account we just deleted.)
    we are almost done. next we have to enable the accounts. This time from 2013 "Exchange Management Shell" run the following commands one at a time.
    Enable-Mailbox –Arbitration “DiscoverySearchMailbox {D919BA05-46A6-415f-80AD-7E09334BB852}”
    Enable-Mailbox –Arbitration “FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042”
    Enable-Mailbox –Arbitration “Migration.8f3e7716-2011-43e4-96b1-aba62d229136”
    Enable-Mailbox –Arbitration “SystemMailbox{1f05a927-0acd-45d5-9bc1-1a123e6fc52e}”
    Enable-Mailbox –Arbitration “SystemMailbox{bb558c35-97f1-4cb9-8ff7-d53741dc928c}”
    Enable-Mailbox –Arbitration “SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}”
    Set-Mailbox "Migration.8f3e7716-2011-43e4-96b1-aba62d229136" -Arbitration –Management:$true
    once you have completed this you will be able to close the Exchange Admin Centre, then log back in and go to Migration tab without any errors.

  • Please,how can I use javamail to implementing draft box on webmail

    please,how can I use javamail to implementing draft box on webmail

    I already can send and receive EMail ��create
    subfolder with javamail in imap server.but I don't
    know how implement draft mailbox with webmail .
    please expert help me . thanksyou can only create subfolders in a imap mail server ,and you can use folder class included in javamail api to access,create,modify and delete subfolders.You also can create subfolders under a subfolder as you want.
    the simple example is:
    //first create mail session
    mailSession=...
    // second create mail store
    mailStore=...
    //third get root folder
    IMAPFolder rootFolder = (IMAPFolder)mailStore.getFolder("INBOX");
    if ((rootFolder==null)||(!rootFolder.exists())) return false;
    //finally create a subfolder "outbox" under root folder "inbox"
    IMAPFolder tmpOutFolder = (IMAPFolder)rootFolder.getFolder("OUTBOX");
    if (tmpOutFolder==null) return false;
    //if the target folder not exist just create it
    //note:when you create a subfolder you can assign its attribute.Details,please read the javamail document.
    if(!tmpOutFolder.exists()) tmpOutFolder.create(Folder.HOLDS_MESSAGES);

  • Reading MS Exchange Eforms using JavaMail

    Hi, I'm trying to emails that are "EForms" from MS Exchange using JavaMail. I have no problem opening Exchange Server inbox and getting message, but the content type is always "plain/text" rather than "multipart/mixed".

    Here is an example of opening a mail store to read emails with a specified subject line and save the attachment to a file.
              // Start a mail session.
              Session session = Session.getDefaultInstance(new Properties(), null);
              // Create and connect a mail store to the "User" mailbox.
              Store store = session.getStore("imap");
              store.connect("exchangeserver.domain.com", "ntdomain\\ntuserid\\exchange_email_alias", "password");
              // Open the inbox.
              Folder folder = store.getFolder("INBOX");
              folder.open(Folder.READ_WRITE);
              // Search for all the emails with a subject of "This is how".
              SearchTerm st = new SubjectTerm("This is how");
              Message[] message = folder.search(st);
              // Process each message.
              for (int i = 0; i < message.length; i++) {
                   // Process each message "atomically".
                   try {
                        // All "Encrypted File" emails should be Multipart Messages
                        Object o = message.getContent();
                        if (o instanceof MimeMultipart) {
                             // Get 2nd part of the message (multi-parts are zero based) should be
                             // an attached file. Write to a temporary area.
                             MimeMultipart mmp = (MimeMultipart)o;
                             MimeBodyPart mbp = (MimeBodyPart)mmp.getBodyPart(1);
                             File fo = File.createTempFile("file", ".dat");
                             FileOutputStream fos = new FileOutputStream(fo);
                             mbp.getDataHandler().writeTo(fos);
                             fos.close();
    =                         //**********************************************************************
                             // Message was processed successfully, delete it.
                             message[i].setFlag(Flags.Flag.DELETED, true);
                   } catch (Exception e) {
                        System.out.println("Error occurred: " + e);
              // Close folder, expunging the deleted messages.
              folder.close(true);
              // Close the store.
              store.close();

  • Move Mailboxes from Exchange 2007 to Exchange 2013 (Could not find a valid mailbox migration for esta organization)

    Hi all, I am in full migration from Exchange 2007 to Exchange 2013 and everything went correctly.
    I have migrated several mailboxes and are working well. But a few days ago, when I try to migrate a mailbox I get the following error and can not migrate:
    "Could not find a valid mailbox migration for this organization"
    Do you know that you can be?
    regards
    Microsoft Certified IT Professional Server Administrator

    Hi,
    From your description, the issue should be related to the migration mailbox. I recommend you check if the following account is existed in ADUC.
    Migration.8f3e7716-2011-43e4-96b1-aba62d229136
    If this account does not exist, you need to run setup /prepareAD and then enable this migration mailbox to check the result.
    Hope this can be helpful to you.
    Best regards,
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Amy Wang
    TechNet Community Support

  • Problem Sending mails in a loop using JavaMail API

    Hello All,
    I am sending emails in a loop(one after the other) using JavaMail API,but the problem is, if the first two,three email addresses in the loop are Valid it sends the Email Properly, but if the Fourth or so is Invalid Address it throws an Exception....
    "javax.mail.SendFailedException: Sending failed;"
    nested exception is:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 450 <[email protected]>:Recipient address rejected: Domain not found......
    So if i want to send hundereds of emails and if one of the Emails inbetween is Invalid the process Stops at that point and i could not send the other emails in the Loop......
    How Could i Trap the exception thrown and handle it in such a way, so that the loops continues ..
    Is there something with the SMTP Server....?
    The code which i am using is as follows....
    <Code>...
    try {
    InitialContext ic = new InitialContext();
    Session session = (Session) ic.lookup(JNDINames.MAIL_SESSION);
    if (Debug.debuggingOn)
    session.setDebug(true);
    // construct the message
    MimeMessage msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(eMess.getEmailSender()));
    String to = "";
    msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(to, false));
    msg.setRecipients(Message.RecipientType.BCC,
    InternetAddress.parse(eMess.getEmailReceiver(), false));
    msg.setSubject(eMess.getSubject());
    msg.setContent(eMess.getHtmlContents(),"text/plain");
    msg.saveChanges();                
    Transport.send(msg);
    } catch (Exception e) {
    Debug.print("createAndSendMail exception : " + e);
    throw new MailerAppException("Failure while sending mail");
    </Code>....
    Please give me any suggestions regarding it....and guide me accordingly..
    Thanks a million in advance...
    Regards
    Sam

    How about something like the code attached here. Be aware it is lifted and edited out of an app we have here so it may require changing to get it to work. If it don't work - don't come asking for help as this is only a rough example of one way of doing it. RTFM - that's how we worked it out!
    SH
    try {
    Transport.send(msg);
    // If we get to here then the mail went OK so update all the records in the email as sent
    System.out.println("Email sent OK");
    catch (MessagingException mex) {
    System.out.println("Message error");
    Exception ex = mex;
    do {
    if (ex instanceof SendFailedException) {
    if (ex.getMessage().startsWith("Sending failed")) {
    // Ignore this message as we want to know the real reason for failure
    // If we get an Invalid Address error or a Message partially delivered message process the message
    if (ex.getMessage().startsWith("Message partially delivered")
    || ex.getMessage().startsWith("Invalid Addresses")) {
    // This message is of interest as we need to process the actual individual addresses
    System.out.println(ex.getMessage().substring(0, ex.getMessage().indexOf(";")));
    // Now get the addresses from the SendFailedException
    SendFailedException sfex = (SendFailedException) ex;
    Address[] invalid = sfex.getInvalidAddresses();
    if (invalid != null) {
    System.out.println("Invalid Addresse(s) found -");
    if (invalid.length > 0) {
    for (int x = 0; x < invalid.length; x++) {
    System.out.println(invalid[x].toString().trim());
    Address[] validUnsent = sfex.getValidUnsentAddresses();
    if (validUnsent != null) {
    System.out.println("Valid Unsent Addresses found -");
    if (validUnsent.length > 0) {
    for (int x = 0; x < validUnsent.length; x++) {
    System.out.println(validUnsent[x].toString().trim());
    Address[] validSent = sfex.getValidSentAddresses();
    if (validSent != null) {
    System.out.println("Valid Sent Addresses found -");
    if (validSent.length > 0) {
    for (int x = 0; x < validSent.length; x++) {
    System.out.println(validSent[x].toString().trim());
    if (ex instanceof MessagingException)
    ex = ((MessagingException) ex).getNextException();
    else {
    // This is a general catch all and we should assume that no messages went and should stop
    System.out.println(ex.toString());
    throw ex;
    } while (ex != null);

  • How to use JavaMail 1.4 with Oracle Application Server 10g (9.0.4.0.0)

    Hi all,
    I'd like to know if it's possible and how to use JavaMail 1.4 with Oracle Application Server 10g (9.0.4.0.0), Windows version.
    With the following code, I can see that the mail.jar used by the server is the one included in the jdk installation :
    // I'm testing InternetAddress.class because I want to use commons-email-1.2.jar that requires mail.jar 1.4 (or higher) and activation.jar 1.1 (or higher)
    // and I know that inside the commons-email-1.2.jar file, I need to call the InternetAddress.validate() method that throws a java.lang.NoSuchMethodError: javax.mail.internet.InternetAddress.validate()V if it is used with mail.jar 1.2.
    Class cls = javax.mail.internet.InternetAddress.class;
    java.security.ProtectionDomain pDomain = cls.getProtectionDomain();
    java.security.CodeSource cSource = pDomain.getCodeSource();
    java.net.URL location = cSource.getLocation();
    System.out.println(location.toString());
    This code returns : file:/C:/oracle/app/jdk/jre/lib/ext/mail.jar and this mail.jar file has an implementation version number: 1.2
    - I've tried to include my own mail.jar (1.4.2) and activation.jar (1.1.1) files in the war file that I deploy, but it doesn't work (the server still uses the same mail.jar 1.2)
    - I've tried to put the mail.jar (1.4.2) and activation.jar (1.1.1) files in the applib directory of my OC4J instance, but it doesn't work (the server still uses the same mail.jar 1.2)
    - I know that a patch exists : I've read the following document: How to Make Libraries such as mail.jar and activation.jar Swappable ? [ID 552432.1]
    This article talks about the Patch 6514136, but this patch only applies to : Oracle Containers for J2EE - Version: 10.1.3.3.0
    Can you please help me ?
    Thanks in advance for your answers,
    Laurent

    I strongly suggest to upgrade to AS 10.1.3 to get this.
    Think of future support of AS 9.0.4. You will get not critical patch updates anymore.
    --olaf                                                                                                                                                                                                                                                                                                               

  • Error while using Javamail...pls help me...

    when i am using javamail for sending mail , i am getting error like,
    C:\jdk1.3\bin\mail>java MailSend
    [email protected] [email protected]
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.MessagingException:
    at javax.mail.Transport.send0(Transport.java:218)
    at javax.mail.Transport.send(Transport.java:80)
    at MailSend.Send(MailSend.java:56)
    at MailSend.main(MailSend.java:73)
    and i define properties like,
    mailProp.put("java", "java");
    where , "java" is my system name, and there is also mail server on my system. and my system is connected with proxy server..
    when i am trying
    mailProp.put("mail.smtp.host", "java");
    then i am getting same type of error...
    so, what is that ? pls help me to solve my error...

    Surely there's more information associated with that MessaginException than
    you've included here.
    Turn on session debugging and run your program again.
    http://java.sun.com/products/javamail/FAQ.html#debug

Maybe you are looking for

  • Intel IMac will not boot OSX Tiger

    Hi guys, I just wanted to let you know that I am reading and trying to do my home work on why my Intel I-Mac will not boot. It all started after running Windows Vista using Apple Boot Camp. I just wanted to list a few things I have tried after gettin

  • RegisterPointerInputTarget() breaks InjectTouchInput() on Windows 8.1 when the user physically touches the screen.

    This is a "working on Windows 8.0 but broken on 8.1" problem. My application is a full screen magnifier. When magnification is turned on, there is no longer a 1:1 relationship between touch screen coordinates and desktop coordinates. So I need a way

  • Dreamweaver Help

    Hello, Every time I try to open Dreamweaver CS4 a message pops up that says: "Could not locate the Resources file in the Configuration folder. This file is required to run Dreamweaver. Please reinstall the application" Could you please help? I am run

  • Do I have to throw it in the carbage p

    Hi!I would like to find a answer! If possible?I have a CREATIVE product soundblaster li've MP3+5. soundcard?(PCI)?and I love it because it has the most wonderfull recorder included in that software-package. I? am using it alrerady many years (in win

  • .Mac Homepage vs. iWeb

    Prior to upgrading to iLife 06, I uploaded photo albums to my .Mac homepage. Now that I am running iLife 06, by default I can only publish photos from iPhoto using iWeb. I noticed that publishing using iWeb creates a site address of ...web.mac.com/xx