Sponsored Content
Operating Systems Linux Replace A File From Email Attachment Post 302777905 by DGPickett on Friday 8th of March 2013 04:16:15 PM
Old 03-08-2013
I did this with shell scripting and a handful of tools, like mail, sed and a base 64 decoder I wrote. The script would receive all mail, and if a message qualified, extract the Word or Excel files, turn them to plain text and extract the info for insertion into an rdbms table. Since I was dealing with a small number of senders using an even smaller number of mail clients, this sufficed. If you look at a mail message using a text editor, you can see the attachment in there.
Code:
------=_NextPart_01CE1C17.9F57CCC0
Content-Location: file:///C:/0CB82234/hwattachment_files/image001.gif
Content-Transfer-Encoding: base64
Content-Type: image/gif
R0lGODlhvgAiANUAAEBigPiYHRWV08/X39/l6p+wvxA6Ye/y9CBHa2B8ljBVdlBvi4+jta+9ynCJ
oFCw3m295EGp2/mlOcTk9PvFgPD4/PqyVv7s1IrK6TKi2SSc1v3lxl624fzSnOLy+ViWurbe8ZjQ
7PmrSP/58fu/cvieK7yXZG98hNuyeb2qjtPr9+qrWafX7rS4nfzYqq2ehP7y40FoiEV8oGecvVBo
fZ6Xh5jE0OyyYeu/hF2w2Ym3vr/K1X+WqgAtVv///wAAACH5BAAAAAAALAAAAAC+ACIAAAb/QJ9w
SCwaj8ikcslsOp/QqHQKvVBKgSyOd6B6v+CweBy1SrLobI1Hbrvf8Lc5TQ+YAPG8fs8Xzut1L3h9
hIWGTjAdZ4CAJQsJQzs8k5SVlpc8O5KYnJMEm5VHA5cFh6ZPLiJpFox0KD1sQjw9tLW2t7iws7m8
tJK4RgcGuA2nxkokFi06EA/OziwjGx2saRI0PTtDu73dut65v7dGC7iQx+hGNxEC7e7tHkQbqlkp
tF2y4N2T+rfitkUY4EKAL51BHzbevYtgZASJACsQ9EBAhFu/W/wu+rJIiwiBYbcGHByJQaE7CEgs
nKC1oKJGXBltAZhJs+bMUcCGKIA5cuQE/5PtMCBpUCuWkh24tB3h2KMJ0224BvU8CAEoB1EgszFB
6g/JUyZfudoyQGBqz6oKMxgZkLVHwSRiayk18nXJ0wMSbxUzBkCkWSI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KNbQzjA55GzMc9gtlCGw2QCE0k
+KjTjGpk0pkJz+ZCJvOcx3UoQoAGe9CX3HksgLEogARnIsFpvSFnqtLUJ1RFQxoeYIapSgIOUVWc
AQxtYdMiigttNQkG4GsTxSEiEMfkQh9Ujlxe8uEkCtBE1oxkdVbMohYRc7ItejGLifuiE4IAADs=
------=_NextPart_01CE1C17.9F57CCC0
Content-Location: file:///C:/0CB82234/hwattachment_files/filelist.xml
Content-Transfer-Encoding: quoted-printable
Content-Type: text/xml; charset="utf-8"
<xml xmlns:o=3D"urn:schemas-microsoft-com:office:office">
<o:MainFile HRef=3D"../hwattachment.htm"/>
<o:File HRef=3D"themedata.thmx"/>
<o:File HRef=3D"colorschememapping.xml"/>
<o:File HRef=3D"image001.gif"/>
<o:File HRef=3D"filelist.xml"/>
</xml>
------=_NextPart_01CE1C17.9F57CCC0--

 

10 More Discussions You Might Find Interesting

1. How do I send email?

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies

2. UNIX for Dummies Questions & Answers

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies

3. Shell Programming and Scripting

UNIX file attachment in email

Hi, I have a syntax for mail attachment as $EMAIL "Wrapper $wrapper_script_name has failed" " $wrapper_script_name has Failed " $failed_email_address and $EMAIL is as below MSGSub=${1} MSGText=${2} RMAIL=${3} #set LANG='' export LANG='' echo "${MSGSub}" | mailx -s "${MSGText}" ... (1 Reply)
Discussion started by: satgur
1 Replies

4. Shell Programming and Scripting

Sending email and attachment file using Perl

I am trying to send an email body of information and also attachment using perl script, but I am only able to send the body but not an attachment. is there around it without using "use MIME::Lite;" module. $user = "bataf\@xyz.com"; $subjectt = "mail from perl"; open(MAIL, "| mailx -s... (1 Reply)
Discussion started by: bataf
1 Replies

5. Shell Programming and Scripting

Send a file through email using cron as an attachment

Hi All, I want to send a file as an attachment through cron job.Is this possible using cronjob nd if it i, can you please let me know how to do this? Thanks (2 Replies)
Discussion started by: NARESH1302
2 Replies

6. UNIX for Advanced & Expert Users

email file as attachment...

Hello all, i am on hp-ux 11.23...i am trying to send an email as an attachement but it dose not seem to work...after reading on google i found that we can use uuencode to send file at attachement...here is my file and the syntax $ cat test.txt NAME --------- TEST $ uuencode... (7 Replies)
Discussion started by: abdul.irfan2
7 Replies

7. Shell Programming and Scripting

Sending a file as an attachment to email

The file is located under appl/batchdata/ file name: storesales.txt I am using following code because uuencode is not present. I am not getting the data in file but i am getting the blank file with same name as an email attachment. ( echo "from: sch@xxxx.com" echo "to:sch@xxxx.com" echo... (2 Replies)
Discussion started by: skatpally
2 Replies

8. Shell Programming and Scripting

Replace A File From Email Attachment

I am looking for a method that would allow me to replace an existing file with one from an email attachment. Any way of scripting this, so when an email comes in from a particular email id, it takes the attached file, and replaces an existing file. (6 Replies)
Discussion started by: evencustard
6 Replies

9. Shell Programming and Scripting

Email with .dat file as attachment

Hi, I am trying to email a .dat file as an attachment from unix MS-outlook. I tried uuencode but it is not attaching the file, rather it is placing some junk data in the body of mail. Below is my code (cat Message.txt; uuencode Attach_File.DAT Attch_File.DAT) | mailx -s "SUBJECT"... (12 Replies)
Discussion started by: sampoorna
12 Replies

10. UNIX for Dummies Questions & Answers

Cronjob output to file AND to email (as attachment)

I have a shell script that runs on our webserver logs, and grabs various useful data and then outputs this data to a .csv file. What I want to do now is schedule a cronjob to run this script for me each week at a designated time, AND email the .csv file that is created as an attachment to... (1 Reply)
Discussion started by: xdawg
1 Replies
Email::Simple(3pm)					User Contributed Perl Documentation					Email::Simple(3pm)

NAME
Email::Simple - simple parsing of RFC2822 message format and headers SYNOPSIS
use Email::Simple; my $email = Email::Simple->new($text); my $from_header = $email->header("From"); my @received = $email->header("Received"); $email->header_set("From", 'Simon Cozens <simon@cpan.org>'); my $old_body = $email->body; $email->body_set("Hello world Simon"); print $email->as_string; ...or, to create a message from scratch... my $email = Email::Simple->create( header => [ From => 'casey@geeknest.com', To => 'drain@example.com', Subject => 'Message in a bottle', ], body => '...', ); $email->header_set( 'X-Content-Container' => 'bottle/glass' ); print $email->as_string; DESCRIPTION
"Email::Simple" is the first deliverable of the "Perl Email Project." The Email:: namespace was begun as a reaction against the increasing complexity and bugginess of Perl's existing email modules. "Email::*" modules are meant to be simple to use and to maintain, pared to the bone, fast, minimal in their external dependencies, and correct. METHODS
new my $email = Email::Simple->new($message, \%arg); This method parses an email from a scalar containing an RFC2822 formatted message and returns an object. $message may be a reference to a message string, in which case the string will be altered in place. This can result in significant memory savings. If you want to create a message from scratch, you should use the "create" method. Valid arguments are: header_class - the class used to create new header objects The named module is not 'require'-ed by Email::Simple! create my $email = Email::Simple->create(header => [ @headers ], body => '...'); This method is a constructor that creates an Email::Simple object from a set of named parameters. The "header" parameter's value is a list reference containing a set of headers to be created. The "body" parameter's value is a scalar value holding the contents of the message body. Line endings in the body will normalized to CRLF. If no "Date" header is specified, one will be provided for you based on the "gmtime" of the local machine. This is because the "Date" field is a required header and is a pain in the neck to create manually for every message. The "From" field is also a required header, but it is not provided for you. header_obj my $header = $email->header_obj; This method returns the object representing the email's header. For the interface for this object, see Email::Simple::Header. header_obj_set $email->header_obj_set($new_header_obj); This method substitutes the given new header object for the email's existing header object. header my @values = $email->header($header_name); my $first = $email->header($header_name); In list context, this returns every value for the named header. In scalar context, it returns the first value for the named header. header_set $email->header_set($field, $line1, $line2, ...); Sets the header to contain the given data. If you pass multiple lines in, you get multiple headers, and order is retained. If no values are given to set, the header will be removed from to the message entirely. header_names my @header_names = $email->header_names; This method returns the list of header names currently in the email object. These names can be passed to the "header" method one-at-a-time to get header values. You are guaranteed to get a set of headers that are unique. You are not guaranteed to get the headers in any order at all. For backwards compatibility, this method can also be called as headers. header_pairs my @headers = $email->header_pairs; This method returns a list of pairs describing the contents of the header. Every other value, starting with and including zeroth, is a header name and the value following it is the header value. body Returns the body text of the mail. body_set Sets the body text of the mail. as_string Returns the mail as a string, reconstructing the headers. crlf This method returns the type of newline used in the email. It is an accessor only. default_header_class This returns the class used, by default, for header objects, and is provided for subclassing. The default default is Email::Simple::Header. CAVEATS
Email::Simple handles only RFC2822 formatted messages. This means you cannot expect it to cope well as the only parser between you and the outside world, say for example when writing a mail filter for invocation from a .forward file (for this we recommend you use Email::Filter anyway). For more information on this issue please consult RT issue 2478, <http://rt.cpan.org/NoAuth/Bug.html?id=2478>. PERL EMAIL PROJECT
This module is maintained by the Perl Email Project <http://emailproject.perl.org/> AUTHORS
Simon Cozens originally wrote Email::Simple in 2003. Casey West took over maintenance in 2004, and Ricardo SIGNES took over maintenance in 2006. COPYRIGHT AND LICENSE
Copyright 2004 by Casey West Copyright 2003 by Simon Cozens This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-12-23 Email::Simple(3pm)
All times are GMT -4. The time now is 10:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy