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

T

Ted Byers

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.

Thanks

Ted
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top