RE: choosing the correct attachment



Sorry to re-post so quickly, but I got it figured out. Thanks!

below....


>
> > Hi Brian
>
> Hello,
>
> >
> > > Hi All,
> > >
> > > I thought I had this figured out but I was wrong. The part
> > I'm having
> > > trouble w/ is getting the loop to attach the correct
> > html_file. Right now
> > > that program will attach this file every time:
> > >
> > > my $html_file = 'c:\brian\test\html\12345.htm';
> >
> > This is exactly what you express with your code, see below:
>
> I've made some minor changes....
> >
> > > What I would like to happen is if f ($_ eq $html) to attach
> > that html doc.
> > > and then the next time through attach the html doc. that eq
> > the next $_
> > >
> > > BTW each .txt file contains random item numbers (text) that
> > matches an html
> > > doc. for example.
> > >
> > > c:\brian\test\orders\10001.txt might include:
> > > 12345.html
> > > 12346.html
> > >
> > > .... so I would like the correct html doc to be attached to
> > that email and
> > > so on...
> > >
> > > The attachment is being renamed to correctly... but I have
> > a feeling if the
> > > program worked correctly, I wouldn't have to rename it
> > attachment.. :~)
> > > Can someone pls help... Thanks!
> > >
> > > #!/usr/bin/perl
> > >
> > > use strict;
> > > use warnings;
> > > use MIME::Lite;
> > > use Net::SMTP;
> > >
> > > my $html_dir = "C:/brian/test/html";
> > >
> > > opendir(DIR, $html_dir) or die "Can't open the $html_dir: $!\n";
> > >
> > > # read file/directory names in that directory into @htmls
> > >
> > > my @htmls = readdir(DIR) or die "Unable to read current dir:$!\n";
> > >
> > > closedir(DIR);
> > >
> > > my $orders_dir = "C:/brian/test/orders";
> > > opendir (ORDERS, $orders_dir) or die "Can't open
> $orders_dir: $!";
> > >
> > > # read all the item numbers in all the .txt files and
> > > # load @ARGV for <> operator
> > >
> > > @ARGV = map { "$orders_dir/$_" } grep { !/^\./ } readdir ORDERS;
> > >
> > > while (<>) {
> > > chomp;
> > > # email information
> > > my $from_address = <mailto:'bvolk@xxxxxxxxx'> 'bvolk@xxxxxxxxx';
> > > my $to_address = <mailto:'bvolk@xxxxxxxxxxxxxx'>
> > 'bvolk@xxxxxxxxxxxxxx';
> > > my $mail_host = 'smtp.bvolk.com';
> > > my $subject = 'Test eMail';
> > > my $message_body = "Attached is the msds for $ARGV";
> > > my $html_file = 'c:\brian\test\html\12345.htm';
>
> I take it I should comment out the line above...

Yes, and I did as well as the $subject


> >
> > Here you specify your file...
> >
> > > foreach my $html (@htmls) {
> > > if ($_ eq $html)
> > > my $msg = MIME::Lite->new (
> > > From => $from_address,
> > > To => $to_address,
> > > Subject => $ARGV,
> > > Type =>'multipart/mixed'
> > > ) or die "Error creating multipart container: $!\n";
> > >
> > > $msg->attach (
> > > Type => 'TEXT',
> > > Data => $message_body
> > > ) or die "Error adding the text message part: $!\n";
> > >
> > > $msg->attach (
> > > Type => 'application',
> > > Path => $html_file,
>
> ... should I change the line above to Path => $html,
> if I do that I get "12345.html: not readable. Any
> ideas? Thanks for the help.

I changed it to Path => "$html_dir/$html",


> >
> > ...which you attach in the above line every time.
> >
> > > Filename => $_,

I also took out Filename => $_ I didn't need to rename the file.

> > > Disposition => 'attachment'
> > > ) or die "Error adding $html_file $!\n";
> > >
> > > MIME::Lite->send('smtp', $mail_host, Timeout=>60);
> > > $msg->send;
> > > }
> > > }
> > > }
> > >
> > > closedir (ORDERS);
> > >
> > >
> > > Brian Volk
> > > HP Products
> > > 317.298.9950 x1245
> > > <mailto:bvolk@xxxxxxxxxxxxxx> bvolk@xxxxxxxxxxxxxx
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> > For additional commands, e-mail: beginners-help@xxxxxxxx
> > <http://learn.perl.org/> <http://learn.perl.org/first-response>
> >
> >
> >
>
.



Relevant Pages

  • RE: choosing the correct attachment
    ... >> trouble w/ is getting the loop to attach the correct ... >> and then the next time through attach the html doc. ... I wouldn't have to rename it ... >> Brian Volk ...
    (perl.beginners)
  • Re: choosing the correct attachment
    ... > trouble w/ is getting the loop to attach the correct html_file. ... > What I would like to happen is if f to attach that html doc. ... I wouldn't have to rename it attachment.. ...
    (perl.beginners)
  • choosing the correct attachment
    ... trouble w/ is getting the loop to attach the correct html_file. ... What I would like to happen is if f to attach that html doc. ... I wouldn't have to rename it attachment.. ... Subject => $ARGV, ...
    (perl.beginners)
  • Re: Imagine This...President Bush singing "Imagine"
    ... I hope I can attach that file to my next email to YO... ... think she might get a giggle out of it, ... playlist was featured on NBC News with Brian Williams... ...
    (rec.music.beatles)
  • Re: Rename Recorded TV
    ... the audio portion of the recorded TV did play. ... > Brian wrote: ... >> Is there a way for non programers like me to rename a file? ... >> simply allow me to rename my TV shows I am off loading from my Ultimate TV, ...
    (microsoft.public.windows.mediacenter)