perl and blobs

S

Sokar

Hello,

I have a perl script that needs to generate an e-mail every day. What it
does it connects to a database and reads in a stored jpg which was in a blob
field to a variable called $pic

What I need to be able to do is e-mail this variable as a jpg to a person.

Does anyone know how I can do this without actually creating a .jpg file on
the server?

Thanks and regards
 
P

phaylon

Sokar said:
Does anyone know how I can do this without actually creating a .jpg file
on the server?

Search CPAN for MIME, the first (MIME::Tools) seems to be what you're
looking for.
 
B

Brian Wakem

Sokar said:
Hello,

I have a perl script that needs to generate an e-mail every day. What it
does it connects to a database and reads in a stored jpg which was in a blob
field to a variable called $pic

What I need to be able to do is e-mail this variable as a jpg to a person.

Does anyone know how I can do this without actually creating a .jpg file on
the server?

Thanks and regards


use MIME::Lite;
my $msg = MIME::Lite->new(
From => $from,
To => $to,
Subject => $subject,
Type =>'multipart/mixed'
);
# add text
$msg->attach(
Type =>'TEXT',
Data => 'This is text in the mail body',
);
# attach image
$msg->attach(Type => 'application/octet-stream',
Data => "$pic",
Filename =>"myfile.jpg",
);
MIME::Lite->send('smtp', 'your.mail.relay', Timeout=>60);
$msg->send;
 

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
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top