Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Re: Re: Re: Using MIME-Lite to send attachment

by tachyon (Chancellor)
on Apr 10, 2004 at 13:27 UTC ( [id://344122]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Using MIME-Lite to send attachment
in thread Using MIME-Lite to send attachment

The error message actually pinpoints it for you. Problem on line 19.....Might be runaway line near '' on line >>>18<<<. The problem is that the \ char ESCAPES other characters so if you want a LITERAL \ you need to type \\ Note that single quotes and backslashes may cause you confusion. See fix below:

# ***** This is the problem ***** # Path =>'C:\a\cursors\', # ***** This works, note \\ and double quotes " ***** Path => "C:\\a\\cursors\\",

Note that \\ in Win32 is a pain. Unless you are executing stuff through the shell using backtics or system you can just use / ie open FILE, "C:/WINNT/system32/some.file" works just fine.

With the error messages they look complex but the problem is usually trivial. Missing ; Forgetting to close quotes (or stating with " and ending with ' or vice versa) and missing braces { } are the most common culprits.

cheers

tachyon

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Using MIME-Lite to send attachment
by rscott212 (Sexton) on Apr 13, 2004 at 01:59 UTC
    Hello. I have one more question. Thanks for all your help so far! I'm still having problems with this script. I think I have it all working except that I now get the error message:
    Can't call method "attach" without a package or object reference
    Can you tell me what this means?

    Rob

      What this means is pretty much what it says! You may well find adding the line 'use diagnostics;' to your code helpful as the diagnostics module will pull some details from the perldocs for you. For example:

      use diagnostics; 0->my_method(); __DATA__ Can't call method "my_method" without a package or object reference at (F) You used the syntax of a method call, but the slot filled by t +he object reference or package name contains an expression that retur +ns a defined value which is neither an object reference nor a package n +ame. Something like this will reproduce the error: $BADREF = 42; process $BADREF 1,2,3; $BADREF->process(1,2,3); Uncaught exception from user code: Can't call method "my_method" without a package or object referenc +e at script line 3

      So above you see an example that generates your error. Diagnostics have expanded the error message (in this case it is not the best explanation I have ever seen but....)

      So the error is I called the method 'my_method' on the value 0. You can't call a method on 0 or an undefined value or in fact anthing that is not a blessed object that supports that method. The error has occurred because your Mime::Lite object is not defined for some reason. Without seeing the code you are currently working with that is all I can say.

      cheers

      tachyon

      Here is an example that works on my Win32 box:

      use MIME::Lite; my $smtp = 'mail.trump.net.au'; # (typically your ISPs SMTP server) my $from = 'james.freeman@smartsurf.org'; my $to = $from; my @cc = qw( ); # add addresses here to Cc, space separated my $sbj = 'A test with attachment'; my @cc = ( "Cc" => (join ',', @cc) ) if @cc; my $msg = MIME::Lite->new( From => $from, To => $to, @cc, Subject => $sbj, Type =>'multipart/mixed', ) or die "Could not create Mime::Lite object!"; $msg->attach( Type =>'TEXT', Data =>"Here's the file you wanted" ); $msg->attach( Type =>'image/gif', # often 'application/octet-stre +am' Path =>"C:\\background.gif", # full path to file Filename =>'background.gif' # name we want to use in email +for file ); #print $msg->as_string; $msg->send_by_smtp( $smtp) or die "Could not send mail $!\n";

      cheers

      tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://344122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-24 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found