How to use MIME::Lite to include the original message in the replywhen replying to a message?

Discussion in 'Perl Misc' started by Ted Byers, Jun 24, 2010.

  1. Ted Byers

    Ted Byers Guest

    I am using Activestate perl 5.10.0 on WXP.

    I now have a script that uses Net::IMAP::Simple to get incoming
    messages, and Email::Simple to parse the headers easily. Once I have
    the information I need from the headers, I use MIME::Lite to send a
    multipart/related message using our MS Exchange server. Once I
    figured it out, the result seems easy and reliable.

    The problem is that I have now been asked to include in the automated
    replies the bodies of the messages the script is replying to, and
    these too are multipart/related. Is there a relatively painless way
    to add the body of the old message as yet another part to the message
    I am sending? My first thought was to get the body from the object
    returned by Email::Simple->new, from which I had already parsed the
    headers, and add those lines of data to the new one using MIME::Lite-
    >build on the old body to make another part to the message I am

    sending, but that produced something incomprehensible (i.e. the result
    was the intended new body with a nameless attachment with only a
    single line of text - none of the data from the original message). It
    is certain that this approach is wrong, but the question is, what
    should I have done?

    If I can get MIME::parser to extract the html part and the images in
    the incoming messages, so I can write those to files, I can then
    create a new part from those files, but I have yet to get MIME::parser
    to parse multipart/related or multipart/alternative messages in a way
    that I can get at either the html part or the images. I suspect I
    haven't really understood, yet, how to use MIME::parser properly with
    multipart messages, but that is a different matter.

    To be clear, it is trivial for me to append an original message to an
    automated reply when the original is plain text (regardless of the
    MIME type of the automated reply), but I am presently at a loss as to
    how to do so when both the automated reply (without the original) and
    the original messages are multipart/related MIME messages (using html
    for the body and various different media either embedded or attached.

    I clearly need a little guidance on which MIME packages I should
    examine, and how to use them to achieve what is required.


    Ted Byers, Jun 24, 2010
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John B. Kim

    MIME::Lite HTML message handling

    John B. Kim, Jan 18, 2004, in forum: Perl
    Joe Smith
    Jan 19, 2004
  2. Andy Fish
    Andy Fish
    May 19, 2004
  3. Aaron Brady

    SQL, lite lite lite

    Aaron Brady, Dec 29, 2008, in forum: Python
    Aaron Brady
    Jan 1, 2009
  4. Jane Humbrey
    Jane Humbrey
    Sep 1, 2003
  5. Replies:
    Dec 10, 2004

Share This Page