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
Mail::Verify(3pm)					User Contributed Perl Documentation					 Mail::Verify(3pm)

NAME
Mail::Verify - Utility to verify an email address SYNOPSIS
use Mail::Verify; DESCRIPTION
"Mail::Verify" provides a function CheckAddress function for verifying email addresses. First the syntax of the email address is checked, then it verifies that there is at least one valid MX server accepting email for the domain. Using Net::DNS and IO::Socket a list of MX records (or, falling back on a hosts A record) are checked to make sure at least one SMTP server is accepting connections. ERRORS
Here are a list of return codes and what they mean: 0 The email address appears to be valid. 1 No email address was supplied. 2 There is a syntaxical error in the email address. 3 There are no DNS entries for the host in question (no MX records or A records). 4 There are no live SMTP servers accepting connections for this email address. EXAMPLES
This example shows obtaining an email address from a form field and verifying it. use CGI qw/:standard/; use Mail::Verify; my $q = new CGI; [...] my $email = $q->param("emailaddr"); my $email_ck = Mail::Verify::CheckAddress( $email ); if( $email_ck ) { print '<h1>Form input error: Invalid email address.</h1>'; } [...] perl v5.8.8 2002-06-09 Mail::Verify(3pm)
All times are GMT -4. The time now is 02:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy