Sponsored Content
Top Forums Shell Programming and Scripting Sending zip file as attachments in perl Post 302546019 by latika on Wednesday 10th of August 2011 08:20:00 AM
Old 08-10-2011
can u just try system command instead of using ` back quotes.
 

10 More Discussions You Might Find Interesting

1. How do I send email?

sending files as attachments

How do I send a file as an attachment on a Unix system (9 Replies)
Discussion started by: SmartJuniorUnix
9 Replies

2. UNIX for Dummies Questions & Answers

sending files as attachments

How do I send a file as an attachment on a Unix system (9 Replies)
Discussion started by: SmartJuniorUnix
9 Replies

3. UNIX for Advanced & Expert Users

sending attachments via unix

Hi, I need to send a mail attachment from the UNIX commandline. I'm using Tru64 and the mail client thats supposed receive the attached file (an excel sheet) is Lotus Notes. Can anybody help me out? (6 Replies)
Discussion started by: Abhishek Ghose
6 Replies

4. UNIX for Dummies Questions & Answers

sending attachments in mail

Hi , i have tried the following command to send an email with an attachment its working fine but i am getting mail with the embeded content inside the mail that too truncated. i wanted it as an attachment. /usr/lib/sendmail -F "MAC SIA" address "rajendra@abc.com.sg" -t <... (6 Replies)
Discussion started by: rajendragora
6 Replies

5. Shell Programming and Scripting

Sending text files as attachments

Hi, I have used the following command to send a text file "archiver.log" as attachment. (cat mail.log; uuencode archiver.log archiver.log; ) | mailx -s "Failure" asd@a.com : But in the mail i am not getting new lines in the text file.New Lines are getting replaced with some weird... (2 Replies)
Discussion started by: radhika03
2 Replies

6. Shell Programming and Scripting

Sending multiple attachments

Hi people, I am new to this forums. I have a quick question I hope one of you could help me with. I am writing a script to send attachments via email. However I am having trouble when trying to send multiple attachments. Here is the code I am using: send_mail() { uuencode $TMP $TMP1 > $TMP1... (1 Reply)
Discussion started by: deo2k8
1 Replies

7. UNIX for Dummies Questions & Answers

Sending email attachments

Hello, I've search the forum, but I cannot find an answer to my specific question. I'm trying to send some files to my professor. Upon his request, I used the following: tar -cvf vh.tar vh_part1.c vh_part2.c vh_part3.c vh_part4.c vh_sample_run15.txt uuencode vh.tar vh.tar > proj1 mail... (2 Replies)
Discussion started by: venush
2 Replies

8. Shell Programming and Scripting

Problem sending excel attachments with MIME::Lite in perl

I am running a perl script that generates an excel doc and then emails it as an attachment. I can generate the excel file fine. I can scp it from the box and open it with no problems. When I send it over email, the file does open properly. The file in email is only 288 B, but on the server it is... (1 Reply)
Discussion started by: Mike_the_Man
1 Replies

9. Shell Programming and Scripting

Sending Multiple Attachments using MAILX

I have created a shell scripts and wanted to email users multiple attachments using mailx. I noticed that when I do a man on mailx I see and -a option for attachments. When I run a: mailx -s "test attachments" -a include_file -a exclude_file testuser@mydomain.com (Interrupt -- one more to... (1 Reply)
Discussion started by: metallica1973
1 Replies

10. UNIX for Dummies Questions & Answers

Sending attachments via unix

OS Linux....Just curious as to why this is not working... uuencode test.txt "test.xls"|mailx -r xxx@server.com -s "validation report" emailrecipient1,emailrecipient2 Please help....Any other options do we need to use?? (3 Replies)
Discussion started by: saggiboy10
3 Replies
TNEF(3) 						User Contributed Perl Documentation						   TNEF(3)

NAME
Convert::TNEF - Perl module to read TNEF files SYNOPSIS
use Convert::TNEF; $tnef = Convert::TNEF->read($iohandle, \%parms) or die Convert::TNEF::errstr; $tnef = Convert::TNEF->read_in($filename, \%parms) or die Convert::TNEF::errstr; $tnef = Convert::TNEF->read_ent($mime_entity, \%parms) or die Convert::TNEF::errstr; $tnef->purge; $message = $tnef->message; @attachments = $tnef->attachments; $attribute_value = $attachments[$i]->data($att_attribute_name); $attribute_value_size = $attachments[$i]->size($att_attribute_name); $attachment_name = $attachments[$i]->name; $long_attachment_name = $attachments[$i]->longname; $datahandle = $attachments[$i]->datahandle($att_attribute_name); DESCRIPTION
TNEF stands for Transport Neutral Encapsulation Format, and if you've ever been unfortunate enough to receive one of these files as an email attachment, you may want to use this module. read() takes as its first argument any file handle open for reading. The optional second argument is a hash reference which contains one or more of the following keys: output_dir - Path for storing TNEF attribute data kept in files (default: current directory). output_prefix - File prefix for TNEF attribute data kept in files (default: 'tnef'). output_to_core - TNEF attribute data will be saved in core memory unless it is greater than this many bytes (default: 4096). May also be set to 'NONE' to keep all data in files, or 'ALL' to keep all data in core. buffer_size - Buffer size for reading in the TNEF file (default: 1024). debug - If true, outputs all sorts of info about what the read() function is reading, including the raw ascii data along with the data converted to hex (default: false). display_after_err - If debug is true and an error is encountered, reads and displays this many bytes of data following the error (default: 32). debug_max_display - If debug is true then read and display at most this many bytes of data for each TNEF attribute (default: 1024). debug_max_line_size - If debug is true then at most this many bytes of data will be displayed on each line for each TNEF attribute (default: 64). ignore_checksum - If true, will ignore checksum errors while parsing data (default: false). read() returns an object containing the TNEF 'attributes' read from the file and the data for those attributes. If all you want are the attachments, then this is mostly garbage, but if you're interested then you can see all the garbage by turning on debugging. If the garbage proves useful to you, then let me know how I can maybe make it more useful. If an error is encountered, an undefined value is returned and the package variable $errstr is set to some helpful message. read_in() is a convienient front end for read() which takes a filename instead of a handle. read_ent() is another convient front end for read() which can take a MIME::Entity object (or any object with like methods, specifically open("r"), read($buff,$num_bytes), and close ). purge() deletes any on-disk data that may be in the attachments of the TNEF object. message() returns the message portion of the tnef object, if any. The thing it returns is like an attachment, but its not an attachment. For instance, it more than likely does not have a name or any attachment data. attachments() returns a list of the attachments that the given TNEF object contains. Returns a list ref if not called in array context. data() takes a TNEF attribute name, and returns a string value for that attribute for that attachment. Its your own problem if the string is too big for memory. If no argument is given, then the 'AttachData' attribute is assumed, which is probably the attachment data you're looking for. name() is the same as data(), except the attribute 'AttachTitle' is the default, which returns the 8 character + 3 character extension name of the attachment. longname() returns the long filename and extension of an attachment. This is embedded within a MAPI property of the 'Attachment' attribute data, so we attempt to extract the name out of that. size() takes an TNEF attribute name, and returns the size in bytes for the data for that attachment attribute. datahandle() is a method for attachments which takes a TNEF attribute name, and returns the data for that attribute as a handle which is the same as a MIME::Body handle. See MIME::Body for all the applicable methods. If no argument is given, then 'AttachData' is assumed. EXAMPLES
# Here's a rather long example where mail is retrieved # from a POP3 server based on header information, then # it is MIME parsed, and then the TNEF contents # are extracted and converted. use strict; use Net::POP3; use MIME::Parser; use Convert::TNEF; my $mail_dir = "mailout"; my $mail_prefix = "mail"; my $pop = new Net::POP3 ( "pop3server_name" ); my $num_msgs = $pop->login("user_name","password"); die "Can't login: $!" unless defined $num_msgs; # Get mail by sender and subject my $mail_out_idx = 0; MESSAGE: for ( my $i=1; $i<= $num_msgs; $i++ ) { my $header = join "", @{$pop->top($i)}; for ($header) { next MESSAGE unless /^from:.*someone@somewhere.net/im && /^subject:s*important stuff/im } my $fname = $mail_prefix."-".$$.++$mail_out_idx.".doc"; open (MAILOUT, ">$mail_dir/$fname") or die "Can't open $mail_dir/$fname: $!"; # If the get() complains, you need the new libnet bundle $pop->get($i, *MAILOUT) or die "Can't read mail"; close MAILOUT or die "Error closing $mail_dir/$fname"; # If you want to delete the mail on the server # $pop->delete($i); } close MAILOUT; $pop->quit(); # Parse the mail message into separate mime entities my $parser=new MIME::Parser; $parser->output_dir("mimemail"); opendir(DIR, $mail_dir) or die "Can't open directory $mail_dir: $!"; my @files = map { $mail_dir."/".$_ } sort grep { -f "$mail_dir/$_" and /$mail_prefix-$$-/o } readdir DIR; closedir DIR; for my $file ( @files ) { my $entity=$parser->parse_in($file) or die "Couldn't parse mail"; print_tnef_parts($entity); # If you want to delete the working files # $entity->purge; } sub print_tnef_parts { my $ent = shift; if ( $ent->parts ) { for my $sub_ent ( $ent->parts ) { print_tnef_parts($sub_ent); } } elsif ( $ent->mime_type =~ /ms-tnef/i ) { # Create a tnef object my $tnef = Convert::TNEF->read_ent($ent,{output_dir=>"tnefmail"}) or die $Convert::TNEF::errstr; for ($tnef->attachments) { print "Title:",$_->name," "; print "Data: ",$_->data," "; } # If you want to delete the working files # $tnef->purge; } } SEE ALSO
perl(1), IO::Wrap(3), MIME::Parser(3), MIME::Entity(3), MIME::Body(3) CAVEATS
The parsing may depend on the endianness (see perlport) and width of integers on the system where the TNEF file was created. If this proves to be the case (check the debug output), I'll see what I can do about it. AUTHOR
Douglas Wilson, dougw@cpan.org perl v5.18.2 2012-07-23 TNEF(3)
All times are GMT -4. The time now is 09:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy