I'm working on a script which is supposed to check an email account and automatically download .doc attachments, but I'm having some problems.
I'm using Mutt to check the email account (IMAP), and I can manually get the attachment and saving it, but I cannot for the life of me work out how to script this, as it involves selecting individual attachments from a list and specifying where to save them?
Any pointers on where to look, or alternatives to Mutt which make this easier?
The work flow is:
Check for new messages.
For each new message - parse the Subject field
make directory under /tmp/mail/ with subject as name (Subject is autogenerated and length controlled)
save attached .doc file in newly created directory
Mark all messages read.
Email reply with synopsis.
The emailing of the synopsis can be done by a script which handles the saved files, I'm adding it only in the interest of completeness.
You shouldn't be trying to automate an interactive program like MUTT. You should be checking the contents of your ~/.maildir yourself, or wherever MUTT keeps its mail. Being descended from a local-mail program, MUTT ought to be keeping its emails in their ordinary plain-text format.
I'm a bit rusty with ~/.maildir things, but:
"Subject:" ought to be a line by itself. I'm less sure how to extract attachments, it probably involves base64 or uuencode. If you mailed a small harmless attachment to yourself, and attached the resulting file found in your .maildir, I could probably work something out.
I thought that Mutt probably was not the right tool to do this with.
The problem with looking at the mailspool directly is that it is an IMAP folder on a remote mailserver. Would it be better to use something like fetchmail to get the mail and process it locally?
I'm pretty happy with grepping for the subject line, but like you, the attachment is what I'm not sure of.
Thanks for the code above anyway, but I was thinking of doing it a little differently.
I would parse the contents of the mailspool and get the info I needed, and then copy the contents of the mailspool to an archive folder and tar+gzip it.
Hi All,
I am new to unix. I have written the script to identify the delimiter count for my source file and the output I have to capture in another file and that file should sent to mail with attachment. I have tried to send the attachment with below script . But I am not able to do that. Any... (2 Replies)
Hi
The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment .
cat Employee.sql
SET VERIFY OFF
SET PAGESIZE 200
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD... (0 Replies)
Hi
Could someone help me with the details on how to send an attachment through mail in unix.
I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps.
Regards
Ajay (2 Replies)
Hi ,
I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Hi,
I am facing an issue while sending a mail from unix with attachment.the issue is i am able to send a mail with attachment but...after receiving the mail if u see that the text is continous though it was line by line in original..
UUENCODE is the cmd i am using...
plz help me in this... (1 Reply)
Dear friends,
Someone please let me know how to store e-mail on local hard disk or floppy disks. I am using UNIX based PINE e-mail programme and the copy of this mail I wanted to store it in my local disks.
Thanks in advance.
Regards,
Rajan (4 Replies)
This question has been asked many time before. I did search other questions. But was not able to work out.
Really sorry for repeating the same question.
I have mail and mailx and sendmail installed.
It Tried this
uuencode FILENAME.txt FILENAME.txt | mail mymail@yahoo.com
the attachment... (3 Replies)