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
CALIBRE-SMTP(1) 						      calibre							   CALIBRE-SMTP(1)

NAME
calibre-smtp - part of calibre SYNOPSIS
calibre-smtp [options] [from to text] DESCRIPTION
Send mail using the SMTP protocol. calibre-smtp has two modes of operation. In the compose mode you specify from to and text and these are used to build and send an email message. In the filter mode, calibre-smtp reads a complete email message from STDIN and sends it. text is the body of the email message. If text is not specified, a complete email message is read from STDIN. from is the email address of the sender and to is the email address of the recipient. When a complete email is read from STDIN, from and to are only used in the SMTP negotiation, the message headers are not modified. Whenever you pass arguments to calibre-smtp that have spaces in them, enclose the arguments in quotation marks. OPTIONS
--version show program's version number and exit -h, --help show this help message and exit -l, --localhost Host name of localhost. Used when connecting to SMTP server. -o, --outbox Path to maildir folder to store failed email messages in. -f, --fork Fork and deliver message in background. If you use this option, you should also use --outbox to handle delivery failures. -t, --timeout Timeout for connection -v, --verbose Be more verbose COMPOSE MAIL Options to compose an email. Ignored if text is not specified -a, --attachment File to attach to the email -s, --subject Subject of the email SMTP RELAY Options to use an SMTP relay server to send mail. calibre will try to send the email directly unless --relay is specified. -r, --relay An SMTP relay server to use to send mail. --port Port to connect to on relay server. Default is to use 465 if encryption method is SSL and 25 otherwise. -u, --username Username for relay -p, --password Password for relay -e, --encryption-method Encryption method to use when connecting to relay. Choices are TLS and SSL. Default is TLS. SEE ALSO
The User Manual is available at http://calibre-ebook.com/user_manual Created by Kovid Goyal <kovid@kovidgoyal.net> calibre-smtp (calibre 0.6.53) July 2010 CALIBRE-SMTP(1)
All times are GMT -4. The time now is 06:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy