freelanceprogrammers.org Forum Index » Perl

Help in Sending results of Database via Email


View user's profile Post To page top
jocua.rm Posted: Wed Sep 15, 2004 7:52 pm


Joined: 15 Sep 2004

Posts: 2
Help in Sending results of Database via Email
Hi,

I`m writing a perl script that would basically do a query and send
the results through email.

This part shows the result for me... I`ve omitted stuff like
connecting to the database and the like.


while (my @row = $sth -> fetchrow_array()) {
my $record = {};
$record ->{`Date`} = $row[0];
$record ->{`City`} = $row[1];
print "@row
";
}
}

This part here sends an email to me.

use MIME::Lite;
my $msg = MIME::Lite->new(
From =>`yyyy@...`,
To =>`xxxx@...`,
Subject =>`Test99.pl`,
Type =>`text/html`,
Data => @row
);

$msg->send;


Now, what when I try to send this result to me, it will give me
this...
HASH(0x83e94a8)HASH(0x83e94d8)HASH(0x83e9508)HASH(0x83e9538)HASH
(0x83e9568)HASH(0x83e9598)HASH(0x83e95c8)

Any help will be greatly appreciated.

Thanks,
Jonathan
Reply with quote
Send private message
View user's profile Post To page top
perl_jam03 Posted: Thu Sep 16, 2004 3:01 am


Joined: 05 May 2004

Posts: 16
Help in Sending results of Database via Email
According to the documentation of MIME::Lite:

<doc>
Data
Alternative to "Path" or "FH". The actual message data. This may be
a scalar or a ref to an array of strings; if the latter, the message
consists of a simple concatenation of all the strings in the array.
</doc>

So I guess your object construction command should use a ref instead of
an array, such as:

my $msg = MIME::Lite->new(
From =>`yyyy@...`,
To =>`xxxx@...`,
Subject =>`Test99.pl`,
Type =>`text/html`,
Data => @row
);

I have never used this module so maybe that`s not it. But when you get
output like the one you are getting, it usually is a dereferencing
issue. Before actually sending the message try printing to the screen
the variables you will send.

Best of luck.
Rex


--- "jocua.rm" <no_reply@yahoogroups.com> wrote:

> Hi,
>
> I`m writing a perl script that would basically do a query and send
> the results through email.
>
> This part shows the result for me... I`ve omitted stuff like
> connecting to the database and the like.
>
>
> while (my @row = $sth -> fetchrow_array()) {
> my $record = {};
> $record ->{`Date`} = $row[0];
> $record ->{`City`} = $row[1];
> print "@row
";
> }
> }
>
> This part here sends an email to me.
>
> use MIME::Lite;
> my $msg = MIME::Lite->new(
> From =>`yyyy@...`,
> To =>`xxxx@...`,
> Subject =>`Test99.pl`,
> Type =>`text/html`,
> Data => @row
> );
>
> $msg->send;
>
>
> Now, what when I try to send this result to me, it will give me
> this...
> HASH(0x83e94a8)HASH(0x83e94d8)HASH(0x83e9508)HASH(0x83e9538)HASH
> (0x83e9568)HASH(0x83e9598)HASH(0x83e95c8)
>
> Any help will be greatly appreciated.
>
> Thanks,
> Jonathan
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/ndFolB/TM
>
--------------------------------------------------------------------~->
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
mikesouthern Posted: Thu Sep 16, 2004 4:37 am


Joined: 16 Jun 2004

Posts: 9
Help in Sending results of Database via Email
You can`t use @row.

You have to use $row instead.


On 9/15/04 6:01 PM, El Rex at rex@... wrote:

>
> According to the documentation of MIME::Lite:
>
> <doc>
> Data
> Alternative to "Path" or "FH". The actual message data. This may be
> a scalar or a ref to an array of strings; if the latter, the message
> consists of a simple concatenation of all the strings in the array.
> </doc>
>
> So I guess your object construction command should use a ref instead of
> an array, such as:
>
> my $msg = MIME::Lite->new(
> From =>`yyyy@...`,
> To =>`xxxx@...`,
> Subject =>`Test99.pl`,
> Type =>`text/html`,
> Data => @row
> );
>
> I have never used this module so maybe that`s not it. But when you get
> output like the one you are getting, it usually is a dereferencing
> issue. Before actually sending the message try printing to the screen
> the variables you will send.
>
> Best of luck.
> Rex
>
>
> --- "jocua.rm" <no_reply@yahoogroups.com> wrote:
>
>> Hi,
>>
>> I`m writing a perl script that would basically do a query and send
>> the results through email.
>>
>> This part shows the result for me... I`ve omitted stuff like
>> connecting to the database and the like.
>>
>>
>> while (my @row = $sth -> fetchrow_array()) {
>> my $record = {};
>> $record ->{`Date`} = $row[0];
>> $record ->{`City`} = $row[1];
>> print "@row
";
>> }
>> }
>>
>> This part here sends an email to me.
>>
>> use MIME::Lite;
>> my $msg = MIME::Lite->new(
>> From =>`yyyy@...`,
>> To =>`xxxx@...`,
>> Subject =>`Test99.pl`,
>> Type =>`text/html`,
>> Data => @row
>> );
>>
>> $msg->send;
>>
>>
>> Now, what when I try to send this result to me, it will give me
>> this...
>> HASH(0x83e94a8)HASH(0x83e94d8)HASH(0x83e9508)HASH(0x83e9538)HASH
>> (0x83e9568)HASH(0x83e9598)HASH(0x83e95c8)
>>
>> Any help will be greatly appreciated.
>>
>> Thanks,
>> Jonathan
>>
>>
>>
>>
>>
>> ------------------------ Yahoo! Groups Sponsor
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
jocua.rm Posted: Fri Sep 17, 2004 12:47 am


Joined: 15 Sep 2004

Posts: 2
Help in Sending results of Database via Email
Thanks... I will try your suggestions.


--- In perl_official@yahoogroups.com, Mike Southern <gb1198@c...>
wrote:
> You can`t use @row.
>
> You have to use $row instead.
>
>
> On 9/15/04 6:01 PM, El Rex at rex@b... wrote:
>
> >
> > According to the documentation of MIME::Lite:
> >
> > <doc>
> > Data
> > Alternative to "Path" or "FH". The actual message data. This
may be
> > a scalar or a ref to an array of strings; if the latter, the
message
> > consists of a simple concatenation of all the strings in the
array.
> > </doc>
> >
> > So I guess your object construction command should use a ref
instead of
> > an array, such as:
> >
> > my $msg = MIME::Lite->new(
> > From =>`yyyy@a...`,
> > To =>`xxxx@y...`,
> > Subject =>`Test99.pl`,
> > Type =>`text/html`,
> > Data => @row
> > );
> >
> > I have never used this module so maybe that`s not it. But when
you get
> > output like the one you are getting, it usually is a
dereferencing
> > issue. Before actually sending the message try printing to the
screen
> > the variables you will send.
> >
> > Best of luck.
> > Rex
> >
> >
> > --- "jocua.rm" <no_reply@yahoogroups.com> wrote:
> >
> >> Hi,
> >>
> >> I`m writing a perl script that would basically do a query and
send
> >> the results through email.
> >>
> >> This part shows the result for me... I`ve omitted stuff like
> >> connecting to the database and the like.
> >>
> >>
> >> while (my @row = $sth -> fetchrow_array()) {
> >> my $record = {};
> >> $record ->{`Date`} = $row[0];
> >> $record ->{`City`} = $row[1];
> >> print "@row
";
> >> }
> >> }
> >>
> >> This part here sends an email to me.
> >>
> >> use MIME::Lite;
> >> my $msg = MIME::Lite->new(
> >> From =>`yyyy@a...`,
> >> To =>`xxxx@y...`,
> >> Subject =>`Test99.pl`,
> >> Type =>`text/html`,
> >> Data => @row
> >> );
> >>
> >> $msg->send;
> >>
> >>
> >> Now, what when I try to send this result to me, it will give me
> >> this...
> >> HASH(0x83e94a8)HASH(0x83e94d8)HASH(0x83e9508)HASH(0x83e9538)HASH
> >> (0x83e9568)HASH(0x83e9598)HASH(0x83e95c8)
> >>
> >> Any help will be greatly appreciated.
> >>
> >> Thanks,
> >> Jonathan
> >>
> >>
> >>
> >>
> >>
> >> ------------------------ Yahoo! Groups Sponsor
> >>
> >>
> >>
> >> Yahoo! Groups Links
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help