Pb:reading mail from Outlook

Hi
the problem is depended on the reception of a message starting from Outlook.
is to say that the message of Content-Type is received: multipart/alternative; in two type one is Content-Type: text/plain; and the other Content-Type: text/html; .
Also, the other part is not received if there is a file attached
the code is:
if(messages[msgnr].isMimeType("multipart/*"))
Multipart multipart = (Multipart)messages[msgnr].getContent();
for(int i = 0;i < multipart.getCount();i++)
Part p = multipart.getBodyPart(i);
String disposition = p.getDisposition();
if (disposition == null) { // When just body
// Check if plain
if (p.isMimeType("text/plain")) {
out.print("<PRE>");
out.print(p.getContent());
out.print("</PRE>");
} else if (p.isMimeType("text/html")){
out.print("<PRE>");
out.print(p.getContent());
out.print("</PRE>");
else if (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE)){
String filename = p.getFileName();
printHyperlink(attachmentLink,
request,response,
messages[msgnr].getMessageNumber() +
"&part=" + i,
"attachment");
else if(messages[msgnr].isMimeType("text/plain"))
out.print("<PRE>");
out.print(messages[msgnr].getContent());
out.print("</PRE>");
else
printHyperlink(attachmentLink,
request,response,messages[msgnr].getMessageNumber() +
"&part=-1",
"open content");

If you get impatient waiting for an answer, don't repost the thread. It makes people hate you. If you post a reply to your first one it will get moved back up to the top.
Here's your old thread, in case you forgot:
http://forum.java.sun.com/thread.jsp?forum=31&thread=307730

Similar Messages

  • Reading mails from outlook express

    hi..
    i m doin a project on Bayesian Filters to detect spam mails.I need to extract mails from microsoft outlook express that are in the .dbx format as text files.Can someone jus help me out with this.. Its urgent!!!
    it should b usin java.I have heard of mbox but dunno how to use that.So please help me out with this
    regards

    i m doin a project on Bayesian Filters to detect spam
    mails.I need to extract mails from microsoft outlook
    express that are in the .dbx format as text files.Can
    someone jus help me out with this.. I bet Microsoft can.
    Its urgent!!!Not to me.
    it should b usin java.Why? I'd say it should be in VB or something.

  • How to get All Mails from outlook

    Hi am reading mail from outlook.. It reads only unread mails. But i want to read all mails. if any one knows please help me..My code is..
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    public class AllPartsClient {
      public static void main(String[] args) {
    Properties props = new Properties();
        String host = "myhost";
        String username = "myuser";
        String password = "mypass";
        String provider = "pop3";
        try {
          Session session = Session.getDefaultInstance(props, null);
          // Connect to the server and open the folder
          Store store = session.getStore(provider);
          store.connect(host, username, password);
          Folder folder = store.getFolder("INBOX");
          if (folder == null) {
            System.out.println("Folder " + folder.getFullName() + " not found.");
            System.exit(1);
        folder.open(Folder.READ_ONLY);
          // Get the messages from the server
          Message[] messages = folder.getMessages();
          for (int i = 0; i < messages.length; i++) {
            System.out.println("------------ Message " + (i+1)
             + " ------------");
            // Print message headers
            Enumeration headers = messages.getAllHeaders();
    while (headers.hasMoreElements()) {
    Header h = (Header) headers.nextElement();
    System.out.println(h.getName() + ": " + h.getValue());
    System.out.println();
    // Enumerate parts
    Object body = messages[i].getContent();
    if (body instanceof Multipart) {
    processMultipart((Multipart) body);
    else { // ordinary message
    processPart(messages[i]);
    System.out.println();
    // Close the connection
    // but don't remove the messages from the server
    folder.close(true);
    catch (Exception e) {
    e.printStackTrace();
    // Since we may have brought up a GUI to authenticate,
    // we can't rely on returning from main() to exit
    System.exit(0);
    public static void processMultipart(Multipart mp)
    throws MessagingException {
    System.out.println("mp.getCount() = "+mp.getCount());
    for (int i = 0; i < mp.getCount(); i++) {
    processPart(mp.getBodyPart(i));
    public static void processPart(Part p) {
    try {
    String fileName = p.getFileName();
    String disposition = p.getDisposition();
    String contentType = p.getContentType();
    if (fileName == null && (Part.ATTACHMENT.equals(disposition)
    || !contentType.equalsIgnoreCase("text/plain"))) {
    // pick a random file name. This requires Java 1.2 or later.
    fileName = File.createTempFile("attachment", ".txt").getName();
    if (fileName == null) { // likely inline
    p.writeTo(System.out);
    else {
    File f = new File(fileName);
    // find a version that does not yet exist
    for (int i = 1; f.exists(); i++) {
    String newName = fileName + " " + i;
    f = new File(newName);
    FileOutputStream out = new FileOutputStream(f);
    // We can't just use p.writeTo() here because it doesn't
    // decode the attachment. Instead we copy the input stream
    // onto the output stream which does automatically decode
    // Base-64, quoted printable, and a variety of other formats.
    InputStream in = new BufferedInputStream(p.getInputStream());
    int b;
    while ((b = in.read()) != -1) out.write(b);
    out.flush();
    out.close();
    in.close();
    catch (Exception e) {
    System.err.println(e);
    e.printStackTrace();
    In this code if Content is Multipart then it is not displaying content..
    Thanks

    Hi
    if i use String provider = "imap"; then it shows the following error message..
    javax.mail.MessagingException: Connection refused: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
    at javax.mail.Service.connect(Service.java:275)
    at javax.mail.Service.connect(Service.java:156)
    at javamail.AllPartsClient.main(AllPartsClient.java:39)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
    at java.net.Socket.connect(Socket.java:507)
    at java.net.Socket.connect(Socket.java:457)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:84)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
    ... 3 more
    pls any one give idea

  • Can't send or receive mail from Outlook

    just purchased a wireless router and hooked up recently. Can access the internet & outlook express but can't get my mail from outlook which is my main email account. Message says can't find exchange server. I can access Outlook from my laptop wirelessly at work but not at home.
    Any suggestions?

    checked the ip address of the computer when its connected to the router using the command promt.(example.....ip address: 192.168.1.100; Default Gateway:192.168.1.1).
    Open an internet browser (ie, mozilla, netscape,etc.). Type at the address bar the default gateway (192.168.1.1). and you will see a username and password promt for your router. Leave the username blank and use admin for your password, if it doesn't work use the password you setup the router to..
    Once you see the setup page.... you'll be at basic setup sub tab under setup. Look for MTU. Set it to MANUAL and LOWER IT TO 1300.  Save the settings. Check your outlook if its working....If its Does't work do this
    Go to Applications and Gaming tab.
    Look for a port triggering sub tab. type it this way
    Application NameTrigger Port RangeIncoming Port Range
    application       triggered range     forwarded range
    E-mai                 l25 ~ 25                   113 ~ 113
    forwarded range is equevalent to incoming port rage...
    hope this will solve your concern.... 

  • I WANT TO IMPORT MAIL FROM OUTLOOK TO TALKTALK

    i want to direct mail from outlook to talktalk.

    Do you mean Outlook, the application included with Microsoft Office, or Outlook Express, the application included with Windows XP, or Outlook.com, the new incarnation of Hotmail/Windows Live Mail?
    Does talktalk have documentation on importing mail? Or on forwarding your old address to your new address?
    I suspect Firefox is not at the center of the process in any case.

  • Export mail from outlook 2002 for Entourage 2004 - how to?

    Hi.
    I've tried for some time now to export my mail from outlook 2002 for Entourage.. Can't say it's been easy, and I still haven't figured it out.
    Can anyone help me with this..
    and .. oh yes.. I'm a newbie at mac.. got it for only about a week or so now..
    please bare with me..

    I don't use contacts but I found this document that should help:
    http://docs.info.apple.com/article.html?artnum=302268
    However it does specify Outlook 2003 or later is required to sync contacts so that will be an issue for you.

  • Can't sent mail from outlook

    I'm a mac.com acount user. for a long time.
    This changed to me.com and later to Icloud.com.
    Since my storage has been set lower on 5GB on 30 sept 2013 its not possible anymore to sent mail from outlook.
    On the 30 sept we got a message to delete some files in the icloud because our memory was to high.
    But after changing to enough space the problems did not go away.
    error: 0x80004005 de bewerking mislukt.
    I can receive all mails from all my .mac and .me accounts.
    And I can sent mails from outlook .com, but I don't want to use that
    Can someone explain what happened and how to make it work
    Thx
    John

    Allan - Here's the other odd thing. Currently, I have my old mail account AND my new MM account both feeding into and out of Outlook. But since adding my MM acct. - even though I set it as my default mail acct. - the hierarchy tree of Outlook folders is still treating my old acct. as king and my new MM acct. as second class. I know, what's that mean? I have my overriding "Personal Folders" folder, with the sub-folders (in addition to customized ones I added) - all of these at the same level - 'Deleted Items'; 'Inbox' (for my old account); 'Junk E-mail'; 'RSS Feeds'; 'Sent Items' and "Search Folders". Then, below that, but at the same hierarchy level as "Personal Folders", I have my MM's root of an IMAP store folder that has as its name my email address, including the "@me.com". Under that, at the same level of importance as my 'Deleted Items', etc. for my old account is my MM account's "Inbox", "Junk E-mail", "Sent" (which, like I said, I created when I sent the first email from my newly created MM account), and "Search Folders"... that's it. If I delete an email from my MM acct., or am in the process of creating an email in my MM acct., I can only find it in the aforementioned "Deleted Items" or "Draft" folders, as my MM acct. doesn't have these. Is this perhaps one indicator of my sent mail synching problem? Or does one have nothing to do with the other? Does Outlook only provide one each of "Drafts", "Deleted Items" and "Outbox" that all accounts share?

  • Getting inner exception "dtd is prohibited in this xml document exchange" while reading emails from outlook

    Getting error "The response received from the service didn't contain valid XML." with inner exception "dtd is prohibited in this xml document exchange" while reading emails from outlook(Not while reading every mail).
    Can anybody please tell me what might be the issue. Below is the code where I am getting error
    FindItemsResults<Item> RetrievedItems=null ;
    RetrievedItems = service.FindItems(FIds, new ItemView(4));
    String[] SignatureList = ConfigurationManager.AppSettings.Get("SignatureTypes").Split(',');
    if (RetrievedItems != null && RetrievedItems.Count() > 0)
    RetrievedItems.ToList().ForEach(x =>
    try
    List<String> Attachments = new List<String>();
    List<String> ScanFileName = new List<String>();
    bool IsAvailable = true;
    //Getting error while Load() - below line of code
    ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).Load();
    Vo.EmailMessage msg = new Vo.EmailMessage();
    msg.MessageId = ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).Id.UniqueId;
    msg.From = ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).From.Address;
    ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).ToRecipients.ToList().ForEach(z => msg.To += z.Address + ",");
    ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).ReplyTo.ToList().ForEach(y => msg.ReplyToEmailAddress += y.Address + ",");
    msg.Subject = ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).Subject;
    msg.Body = ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).Body.Text;
    msg.Dated = ((Microsoft.Exchange.WebServices.Data.EmailMessage)x).DateTimeSent;
    Please help.

    Hi,
    Thank you for your post.
    This is a quick note to let you know that we are performing research on this issue.
    Niko Cheng
    TechNet Community Support

  • Archiving E-mails from Outlook 11

    In Windows versions it was possible to Archive E-mails from Outlook into one acrobat file. This was so useful and was a great way to clear out old projects and e-mails that might be needed at a later date. I have spent a small fortune in moving from Windows to MAC with also purchasing Office and Acrobat Pro to now find problems such as this is very annoying .
    I see in the Adobe Video a link to combine E-mails into a PDF. But its not there on my MAC. Will there be an update to address this very useful feature or am I missing something.

    I wouldn't hold your breath waiting. Many of us have been trying to get the Acrobat team to give more feature equity with Windows for years. The Acrobat team is mainly focused on the Enterprise market, and they haven't yet learned that more Enterprise customers are moving to the Mac. Maybe by Acrobat 20!

  • Java Mail - problems receiving HTML mail from outlook

    Hello,
    I have a problem with receiving HTML mails from outlook. What I want to do is the following
    - receiving a HTML mail - like a newsletter- send via Outlook
    - display the mail via my mail client in a jtextpane
    I tried it with the following code - but without success :
    a)
    Message msg = message;                    ByteArrayOutputStream os = new ByteArrayOutputStream();     
    message[i].getDataHandler().writeTo(os);
    String data = new String(os.toByteArray());
    textPane.setText(data);
    b)
    StringBuffer sb = null;
    Multipart mp = (Multipart)message[i].getContent();
    for (int j = 1; j < count; j++){
    sb = new StringBuffer();
    InputStream is = mp.getBodyPart(j).getInputStream();
    int c;
    while ((c = is.read()) != -1)
    sb.append((char) c);
    is.close();
    textPane.setText(sb.toString());
    Thanks,
    Mario

    This is what i use and it works just fine
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class sendMail {
    public sendMail(String To,String Subject,String message) {
    String to = To, subject = Subject, from = null,
              cc = null, bcc = null, url = null;
         String protocol = null, host = null, user = null, password = null;
         boolean debug = false;
         try{
    Properties props = System.getProperties();
         Session session = Session.getDefaultInstance(props, null);
         Message msg = new MimeMessage(session);
         if (debug)
              session.setDebug(true);
    msg.setFrom(new InternetAddress("[email protected]"));
         msg.setRecipients(Message.RecipientType.TO,
                             InternetAddress.parse(to, false));
         msg.setSubject(subject);
    msg.setText(message);
         msg.setHeader("Mail","test.com");
         msg.setSentDate(new Date());
         Transport.send(msg);
         System.out.println("\nMail was sent successfully.");
         } catch (Exception e) {
         e.printStackTrace();

  • Reading mails from Hmail Server

    hi all,
    I am using an java mail api to read mails from a hmail server.I was successfull in reading mails and analysing it further but the problem that i face is my program could read only the recent mails ,all the remaining unread mails were not accessible from the java code.......i am attaching my code...
    package mail.hmailserver;
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    public class ReadMail_frm_hmailserver {
         int c=0;
    @SuppressWarnings("unchecked")
    public static void main(String args[]) throws Exception {
    ReadMail_frm_hmailserver mailObj=new ReadMail_frm_hmailserver();
    mailObj.readMails();
    public Vector[] readMails() throws Exception
         String host = "172.29.19.78";
    String user = "[email protected]";
    String password = "testuser1";
    // Get system properties
    Properties properties = System.getProperties();
    // Get the default Session object.
    Session session = Session.getDefaultInstance(properties,null);
    // Get a Store object that implements the specified protocol.
    Store store = session.getStore("pop3");
    //Connect to the current host using the specified username and password.
    store.connect(host, user, password);
    //Create a Folder object corresponding to the given name.
    Folder folder = store.getFolder("inbox");
    // Open the Folder.
    folder.open(Folder.READ_ONLY);
    //folder.open(Folder.READ_WRITE);
    Message[] message = folder.getMessages();
    // String [] contents=new String[10];
    Vector [] contents = new Vector[message.length];//creating array of vectors to store mails
    // Vector contents1=new Vector();
    System.out.println("No of mails : " + message.length);
    System.out.println("subject 1 : "+message[0].getSentDate());
    System.out.println("subject 2 : "+message[0].getSubject());
    // System.out.println("subject 3 : "+message[2].getSubject());
    // System.out.println("subject 4 : "+message[3].getSubject());
    //System.out.println("-----------------");
    // Display message.
    for (int i = 0; i < message.length; i++) {
              c=0;
              contents[i] = new Vector(); //since vector array is an array of arrays we hav to initilize each of the content vectors
    System.out.println("------------ Message " + (i + 1) + " ------------");
    System.out.println("SentDate : " + message.getSentDate());
    System.out.println("From : " + message[i].getFrom()[0]);
    System.out.println("Subject : " + message[i].getSubject());
    System.out.print("Message : ");
    //System.out.println(message[i].getContent());
    Multipart multipart = (Multipart) message[i].getContent();
    //System.out.println(multipart.getCount());
    String line = null;
    for (int j = 0; j < multipart.getCount(); j++) {
    //System.out.println(i);
    //System.out.println(multipart.getContentType());
    BodyPart bodyPart = multipart.getBodyPart(j);
    InputStream stream = bodyPart.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(stream));
    while (br.ready()) {         
         try {
                                  //line.append(br.readLine());
              //line=line+"\n"+br.readLine();
              line=br.readLine();
              if(line.equals("NOTICE")){
                        System.out.println("entered-----------------------------exit loop");
                        //exit();
                        c++;
                        break;
              if(c==0)
              contents[i].add(line); //adding the mails line by line to the array
                             System.out.println(line);
              //System.out.println(contents[i].get(j));
         } catch (Exception e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                                  System.out.println("Exception : "+e);
         //contents[1].add(line);
    System.out.println();
    //System.out.println(line);
    // contents[i].add(line); //adding the mails line by line to the array
    System.out.println();
    // folder.close(true);
    //store.close();
    //System.out.println(contents.length);
    //System.out.println(contents[0].get(0));
    //System.out.println(contents[0].);
    return contents;

    You might want to use IMAP to read mail from hMail Server, if you keep messages on server. It has a lot more features for managing messages on server.
    A lot of POP3 implementations (both client and server side) will automatically delete retrieved messages. I don't know exactly what JavaMail does in that regard, nor of hMailServer, but I do know some mailservers out in the wild will ALWAYS delete mails retrieved with POP3.

  • How to get mail from Outlook to SAP GUI (workflow)

    Hi All ,
    How can we get a mail from outlook or personal mail into SAP GUI .
    can it be used as an event for 'wait for event step ' in workflow . ?
    Thanks ,
    Naval bhatt

    Hi Naval,
    I just want to clarify some areas from your question:
    1. Will a workflow be triggered because of the email from Outlook to SAP? Does it always have to start from the Outlook side?
    The integration of SAP Workplace (thru Workflow) and Outlook is possible using the Extended Notification (tcode SWNCONFIG). Here, you can send an email from SAP to Outlook then execute a function from your Outlook message and then you will be directed to the tcode of SAP side (SAP GUI).
    Regards,
    Reymar

  • How to skip dialogue box which ask you to confirm the operation when your used labview to send an e-mail from Outlook?

    I'm using Labview to send an e-mail from outlook and everytime I got a dialogue box which inform that a software is trying to send an e-mail. To send this e-mail I have to confirm operation. How can I avoid this dialogue box ?

    I don't know what code you're using but the attached VI works with my version of Outlook and doesn't have any pop-up messages. I downloaded it from somewhere a while ago but don't remember where it was from.
    Attachments:
    Email_sender.vi ‏54 KB

  • Reading mails from Zimbra inbox.

    Hi,
    I have a basic program to read the inbox of a zimbra mail user.
    i have supplied the necessary information like username passwd,
    Can someone please tell me what is the pop server required for the Zimbra mail client.
    i know it is somethign do with the LDAP. but how do i find tht out?

    You might want to use IMAP to read mail from hMail Server, if you keep messages on server. It has a lot more features for managing messages on server.
    A lot of POP3 implementations (both client and server side) will automatically delete retrieved messages. I don't know exactly what JavaMail does in that regard, nor of hMailServer, but I do know some mailservers out in the wild will ALWAYS delete mails retrieved with POP3.

  • Migrate Mails From Outlook (mac) To Outlook (windows) ?

    Hi Everybody,
    I am in search of best solution for transferring mails from outlook (mac) to outlook (windows). There are a lot of mails that i need to transfer. I have looked into many forums for the solutions but most are for making IMAP account and all. I don't have such
    a good technical hand in doing such stuff, so i am looking for other alternatives. Fast and Problem solving answers will be really appreciated.
    Thank you

    just needed to add alittle info in this thread...
    I was also looking for solution to import my outlook for mac mails to windows outlook and I was taken to olm to pst converter pro website via this thread. 
    The information that i wanted to add is that Olm to pst converter pro is available in mac version too, which allowed me to convert outlook for mac files into pst format in just a few clicks and  the only thing I had to do is transfer the converted
    pst file and import it into windows outlook.
    I got this tool here: http://olmtopstconverterpro.com/download-olm-to-pst-converter-pro-instant-digital-download/
    Tha whole process was completed in merely 15-18 mins which is the fastest results I have found til now. I hpoe that in information also helps other looking for solution to migrate outlook for mac files to windows outlook.
    Thank you

Maybe you are looking for

  • PSE8 Trying Extracting downloaded file "ARE THE FILE CORRUPT" Win Vista

    have bought online Both Adobe Photoshop Elements 8 (Windows,Svenska) Adobe Premiere Elements 8 (Windows,Svenska) With Adobe Premiere Elements 8 I had no problems but when Photoshop are going to extract the files there will be an error. I have downloa

  • Broken reset button covered by warranty?

    Whilst trying to reset up my TC, I've managed to snap the reset button. I'm guessing this is going to void the warranty, although it didn't seem to give any, and all I did was push it in trying to feel it give any, when snap! Any ide if this would be

  • Best Way to Replicate Azure SQL Databases to Lower Environments

    I have XML files delivered to my server where they are parsed into reference data and written to a database (Premium tier).  I want to have that database sync to other databases (Basic tier) so that my non-production environments can use the same ref

  • Thrown out of exception error

    Hi I wrote a method which gets number of names and picks a random.I had to use buffer reader in order to access the file but I can not use that method in the other methods anymore .when ever I type the method i get this error:unreported exception jav

  • 404 Error when trying Report fault online

    Hi, I can't log fault online as I get webpage not found (error 404) when clicking link. Same when using IE or Firefox. I have had no dial tone for a day (just silence). Broadband is intermittent; crashing every few minutes. Have tried removing everyt