Results 1 to 7 of 7

Thread: Get Email details from Message Object ( Message.java or ParsedMessage.java)

  1. #1
    legalizenet is offline Junior Member
    Join Date
    Oct 2007
    Posts
    6
    Rep Power
    7

    Default Get Email details from Message Object ( Message.java or ParsedMessage.java)

    How do I get email details like

    # Text Body
    # HTML Body

    from Message object (Message.java or ParsedMessage.java) ?.

  2. #2
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default

    Look at ToXML.java and the functions in Mime.java that they call.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  3. #3
    legalizenet is offline Junior Member
    Join Date
    Oct 2007
    Posts
    6
    Rep Power
    7

    Default

    Thanks for the reply. So I did following to get the text content out the email

    List<MPartInfo> parts = Mime.getParts(mMimeMessage);
    MPartInfo body = Mime.getTextBody(parts, false);
    InputStream is = body.getMimePart().getInputStream();
    String emailBody = getStringContent(is); //custom method to extract String out of inputstream.

    Now I have another problem here. when I look at the email body string I see encoded characters like "=E2=80=99" in the whole body. e.g.

    "Word on the street is that Best Buy - which already had photo-sharing throu=
    gh Kodak - didn=E2=80=99t ......"

    Now This is a problem when I have to take this String and save it to the DB via some persistance layer like Hibernate or so. Hibernate pukes out when it sees these characters and if I manually remove these characters data gets saved just fine. Any idea on what level I should be decoding these characters. Infact this comes out in Mime itself. so right from the email source text comes like this.

    -regards,

  4. #4
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default

    I think you have a broken test message. The "=EF" characters you're seeing are quoted-printable-encoded characters. JavaMail says that Part.getInputStream() should do the following:
    Return an input stream for this part's "content". Any mail-specific transfer encodings will be decoded before the input stream is provided.
    So if you're seeing QP-encoded characters, my guess is that either (a) your message is missing the Content-Transfer-Encoding: quoted-printable header line, or (b) you're calling MimeBodyPart.getContentStream() method instead.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  5. #5
    legalizenet is offline Junior Member
    Join Date
    Oct 2007
    Posts
    6
    Rep Power
    7

    Default

    Let me answer your questions first in >>>

    So if you're seeing QP-encoded characters, my guess is that either (a) your message is missing the Content-Transfer-Encoding: quoted-printable header line, or
    >>> Email message has the Content-Transfer-Encoding: quoted-printable, The header looks something like this in the email file

    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: quoted-printable



    (b) you're calling MimeBodyPart.getContentStream() method instead.
    >>> Infact Im using Zimbra's ByteUtil.getContent(is, 0) to get the String out of Inputstream. I tried changing it to Mime.getStringContent(<mimepart>); not much luck either.


    Now this is what I'm doing.

    # I have Zimbra (client and server) installed on my laptop (mac os x)
    # I went to some random web page on the net, took at block of text , opened the Zimbra Mail client , created a new mail (HTML enabled: by selecting 'Format as HTML' under 'Options'), pasted the copied text from the webpage

    # Sent an email to some address.
    # Because I have server on the same machine, I capture the email sent out and that email has a body which has those =E2=80=99 characters.

    (e.g The copied text from the web page on the internet was something like Mydeo’s which gets looks like Mydeo=E2=80=99s in the email message file)

    Now this is via Zimbra client.

    Now If I try same thing with something like GMAIL , it works fine and email message file is encoded properly. the word looks like Mydeo's in Gmail email message file. and I see following in GMail mail message file

    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: 7bit

    So how do I resolve this issue?

    regards,

  6. #6
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default

    Quote Originally Posted by legalizenet View Post
    (b) you're calling MimeBodyPart.getContentStream() method instead.
    >>> Infact Im using Zimbra's ByteUtil.getContent(is, 0) to get the String out of Inputstream. I tried changing it to Mime.getStringContent(<mimepart>); not much luck either.
    I'd need to see a copy of your message to reproduce this. This seems odd, however, as the same code path is used to render the message in the web client. If you don't see the "=E2=80=99" when you view the message in the web client, there's probably something off in your code...
    Quote Originally Posted by legalizenet View Post
    Now If I try same thing with something like GMAIL , it works fine and email message file is encoded properly. the word looks like Mydeo's in Gmail email message file. and I see following in GMail mail message file

    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: 7bit
    Zimbra defaults to utf-8 as the charset for outbound mail (though you can override this in 5.0). Gmail apparently defaults to iso-8859-1. Had you pasted in some chinese characters, Gmail would have used utf-8 as well.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  7. #7
    legalizenet is offline Junior Member
    Join Date
    Oct 2007
    Posts
    6
    Rep Power
    7

    Default

    Here is the actual email message file as I received from Zimbra, you will see those =E2=80=99 characters

    Delivered-To: legalizenet@mycompanyinc.com
    Received: by 10.142.49.10 with SMTP id w10cs35431wfw;
    Tue, 30 Oct 2007 17:15:23 -0700 (PDT)
    Received: by 10.140.249.20 with SMTP id w20mr3671012rvh.1193789723849;
    Tue, 30 Oct 2007 17:15:23 -0700 (PDT)
    Return-Path: <legalizenet@fabfab.com>
    Received: from mail.mycompany.com ([69.190.211.52])
    by mx.google.com with ESMTP id l27si13913408rvb.2007.10.30.17.15.23;
    Tue, 30 Oct 2007 17:15:23 -0700 (PDT)
    Received-SPF: neutral (google.com: 69.190.211.52 is neither permitted nor denied by best guess record for domain of legalizenet@fabfab.com) client-ip=69.190.211.52;
    Authentication-Results: mx.google.com; spf=neutral (google.com: 69.190.211.52 is neither permitted nor denied by best guess record for domain of legalizenet@fabfab.com) smtp.mail=legalizenet@fabfab.com
    Received: from localhost (localhost [127.0.0.1])
    by mail.mycompany.com (Postfix) with ESMTP id CEE5370C26B;
    Tue, 30 Oct 2007 17:15:27 -0700 (PDT)
    X-Virus-Scanned: amavisd-new at
    X-Spam-Flag: YES
    X-Spam-Score: 7.26
    X-Spam-Level: *******
    X-Spam-Status: Yes, score=7.26 tagged_above=-10 required=6.6 tests=[AWL=0.184,
    BAYES_50=0.001, HELO_LOCALHOST=3.941, HTML_MESSAGE=0.001,
    RCVD_IN_XBL=3.033, RDNS_NONE=0.1]
    Received: from mail.mycompany.com ([127.0.0.1])
    by localhost (mail.mycompany.com [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id dQpinndPRLqc; Tue, 30 Oct 2007 17:15:25 -0700 (PDT)
    Received: from localhost (unknown [63.146.69.17])
    by mail.mycompany.com (Postfix) with ESMTP id 2C3D470C26A
    for <legalizenet@mycompany.com>; Tue, 30 Oct 2007 17:15:25 -0700 (PDT)
    Received: from localhost (localhost [127.0.0.1])
    by localhost (Postfix) with ESMTP id 50BF92A94F1
    for <legalizenet@mycompany.com>; Tue, 30 Oct 2007 17:15:35 -0700 (PDT)
    X-Virus-Scanned: amavisd-new at
    Received: from localhost ([127.0.0.1])
    by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id bJz5kZP-iW2P for <legalizenet@mycompany.com>;
    Tue, 30 Oct 2007 17:15:28 -0700 (PDT)
    Received: from localhost (localhost [127.0.0.1])
    by localhost (Postfix) with ESMTP id 4EA5F2A94C8
    for <legalizenet@mycompany.com>; Tue, 30 Oct 2007 17:15:28 -0700 (PDT)
    Date: Tue, 30 Oct 2007 17:15:27 -0700 (PDT)
    From: "Legalize net" <legalizenet@fabfab.com>
    To: legalizenet <legalizenet@mycompany.com>
    Message-ID: <14227494.91193789727905.JavaMail.root@legalize-nets-computer.local>
    Subject: Best Buy takes minority stake in Mydeo for video sharing
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
    boundary="----=_Part_0_12345558.1193789727888"
    X-Originating-IP: [127.0.0.1]

    ------=_Part_0_12345558.1193789727888
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: quoted-printable

    While every online video site wrestles with trying to make social video pay=
    , a small UK-based startup has stuck to its belief that not everyone wants =
    to share the videos of their family and kids with the whole world. Thus, My=
    deo has been rewarded today with an undisclosed minority equity investment =
    by retailer Best Buy, which will use Mydeo=E2=80=99s platform for its bespo=
    ke video sharing service, reports TechCrunchUK. Best Buy Video Sharing is a=
    subscription-based service for users to upload their personal videos for s=
    torage, but also allows them to share select videos on web sites and blogs,=
    while controlling who views the video.=20

    Word on the street is that Best Buy - which already had photo-sharing throu=
    gh Kodak - didn=E2=80=99t want a combined photo/video service and, incredib=
    ly enough, couldn=E2=80=99t find a US-based company that could do what they=
    wanted. However, I have a hunch that since Mydeo is built on Microsoft=E2=
    =80=99s Movie Maker software there may have been some useful introductions =
    made at Microsoft level. Best Buy, the largest electronics retailer in the =
    US, sells around a third of all video cameras sold each year. Significantly=
    , a large percentage of those are sold to Mydeo=E2=80=99s target audiences =
    of families and small businesses, who tend to use Movie Maker. Hey, it may =
    not be cool, but it=E2=80=99s a fact.=20

    Whatever the details of the deal, it=E2=80=99s a good one for Mydeo=E2=80=
    =99s co-founders Cary Marsh and Iain Millar, who started out in 2005 from a=
    small South West London office with local municipal grants.=20


    ------=_Part_0_12345558.1193789727888
    Content-Type: text/html; charset=utf-8
    Content-Transfer-Encoding: quoted-printable

    <html><head><style type=3D'text/css'>body { font-family: 'Times New Roman';=
    font-size: 12pt; color: #000000}</style></head><body>While every online vi=
    deo site wrestles with trying to make social video pay, a small UK-based st=
    artup has stuck to its belief that not everyone wants to share the videos o=
    f their family and kids with the whole world. Thus, Mydeo has been rewarded=
    today with an undisclosed minority equity investment by retailer Best Buy,=
    which will use Mydeo=E2=80=99s platform for its bespoke video sharing serv=
    ice, reports TechCrunchUK. Best Buy Video Sharing is a subscription-based s=
    ervice for users to upload their personal videos for storage, but also allo=
    ws them to share select videos on web sites and blogs, while controlling wh=
    o views the video.<br><br>Word on the street is that Best Buy - which alrea=
    dy had photo-sharing through Kodak - didn=E2=80=99t want a combined photo/v=
    ideo service and, incredibly enough, couldn=E2=80=99t find a US-based compa=
    ny that could do what they wanted. However, I have a hunch that since Mydeo=
    is built on Microsoft=E2=80=99s Movie Maker software there may have been s=
    ome useful introductions made at Microsoft level. Best Buy, the largest ele=
    ctronics retailer in the US, sells around a third of all video cameras sold=
    each year. Significantly, a large percentage of those are sold to Mydeo=E2=
    =80=99s target audiences of families and small businesses, who tend to use =
    Movie Maker. Hey, it may not be cool, but it=E2=80=99s a fact.<br><br>Whate=
    ver the details of the deal, it=E2=80=99s a good one for Mydeo=E2=80=99s co=
    -founders Cary Marsh and Iain Millar, who started out in 2005 from a small =
    South West London office with local municipal grants.<br><br></body></html>
    ------=_Part_0_12345558.1193789727888--

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. One account not receving email
    By EnglishDude in forum Administrators
    Replies: 12
    Last Post: 04-30-2010, 06:19 AM
  2. Email Message will not display
    By jwilso2 in forum Developers
    Replies: 3
    Last Post: 08-02-2009, 10:47 PM
  3. need advice on configuring zimbra to work with fax server
    By pheonix1t in forum Administrators
    Replies: 0
    Last Post: 07-11-2007, 07:46 PM
  4. upgrade to 4.0.3 antispam does'nt work
    By lucanannipieri in forum Administrators
    Replies: 14
    Last Post: 11-07-2006, 03:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •