Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending e-mail with html file as body

Status
Not open for further replies.

zincyo

Programmer
Jun 13, 2007
35
US
Hey,

I need to be able to export a spreadsheet as an htm file (which I have already done) and then using perl code have it automatically e-mailed, and placed into the body as html.

Essentially, I need my code to attach the entire file (which I have already accomplished), and then have this one specfic table displayed as html in the body of the e-mail.

So, I took the file, opened it and put it into an array, however now i'm not sure what to do.

In the beginning of my code I have:
open(Report, "Report.htm") || die("Could not open file!");

@data = <Report>;
chomp @data;

close(Report);

---------------------------------

Then later in my code, when I try and put this file into the body of the html, I was using:
$msg->attach(



Type =>'TEXT/HTML',



Data => while (<>) { join(' ', @data), "\n" },


);

however this doesn't work.


Any help would be greatly appreciated!

 
try:

Code:
Data     => join('    ', @data), "\n",

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hi,

Use something like this to send the email:

open(MAIL, "|/usr/sbin/sendmail -t")||&ErrorMessage;
print MAIL"To: $sendmail1\@$sendmail2 \nFrom: support\@mywebsite.com\nSubject: mywebsite.com private message sent\nYour private message to $recipient has been sent\n\n$pm \n";
close(MAIL);

Be sure the path to your server's sendmail is correct. Call the cells in your array like this:

$array[0]

Then, put that variable in your email.

Be sure that the html in your email has \ in front of weird characters such as @ (as in \@). Look up/experiment to see which are the weird characters.

My program is similar. It also finds something in an array and puts it into an email message. Shameless plug: Please look over my post and help solve my problem:

Hope this helps,
Lilly :)
 
Actually, it looks like they are using the MIME::Lite module to send the email.

I did not take the time to read the original question properly so my reply above will probably not be of any help.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
actually, Kevin-- you are correct in that I am using MIME::Lite, however your response was correct, it works perfectly now. Thanks a lot!
 
hehehe.... I got lucky on that one [smile]

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top