How to delete all mail attachments of a set of mails - email-attachments

In order to save diskspace, I would like to remove all file attachments of a set of mails (let's say 100) in one folder.
I think this must be possible with Mutt and some scripting. For instance using the program altermime.
Ideally, a note is left in the mail specifying that an attachment of a given name has been deleted.
How could this be done?

Related

Procmail mail to file

i want to configure procmail. Right now i've got code to redirect mails with selected topic from server mail to my mail. It's my code:
:0 c
*Subject.*ExampleTopic
Example#Mail.com
I want to copy mail content to selected .txt file on server. How can i do it?
Your current code saves a copy to a folder named Example#Mail.com. To save to a file with a different name, simply change that string. (To forward each matching message to another email address, the syntax is ! Email#example.com with an exclamation mark as the action "verb".)
The default saving action appends to a flat text file in Berkeley mbox format. This includes both the headers and the body. With a b flag you can save just the email body, but this is still the raw MIME transport format, which is very rarely what you actually want.
:0b
* some condition, perhaps
bodyfile.txt
Procmail regrettably knows nothing about MIME, so if getting a particular body part is what you actually need, you'll probably want to pipe the message to some script which understands MIME and can implement your extraction policy.
:0
* some condition, maybe
| extracttool >>bodyfile.txt
The vague wording of your question implies that you are probably not too familiar with the details of email formatting in general and MIME in particular. You'll probably want to post another question with more detailed requirements once you have a proper idea of what the challenges are. For a start, the source of a message you want to mainpulate might help us help you.

Splitting Emails with MIME::Parser

I got handed 4GB of emails concatenated into a single file and the suggestion that MIME::Parser could split the individual emails back out again. All my attempts to date end up with the parser just copying the original file without extracting any of the emails. So: Is this even something that MIME::Parser can handle? My code is very basic:
my $file = IO::File->new("somefile", O_RDONLY);
my $parser = new MIME::Parser;
$parser->output_dir("somedir");
my $entity = $parser->parse($file);
$file->close;
Below is a link to sample date that some have requested. This is all SPAM and phishing emails. DO NOT CLICK ANY OF THE LINKS. Enjoy: Pastbin of 4KB of emails.
MIME::Parser is for reading a single Mail to get the attachments etc. It can be used to extract mails which are attached inside another mail as message/rfc822, but is is not intended to extract mails from some kind of archive with lots of mails in it concatenated.
It is not clear what format your single file with mails has. But if it comes from a UNIX system or from a Thunderbird installation it might simply be in the classical Mbox format and there are several tools to split Mbox files into separate messages. Apart from several perl modules there are also other tools like git-mailsplit which help you extract the mails from Mbox-format.

How to attach a flat file into informatica Email?

I want to send a mail to some users after workflow is done. This email should contain 3 xls file or 1 xls file with 3 sheets. The xls file contains a query result -less than 50 rows- which is loaded by a task dynamically on each run of the workflow.
So in Informatica I couldn't see an option inside the "Email" task to attach anything. Can you help me please?
You cannot send emails with attachments using the Email task (don't ask me why, I cannot imagine any reason for that and this is how it is).
However, sessions can send emails and these emails may contain attachments - the appropriate options are on the Components tab, the variable you need is %a<>.
More information: How to attach new files to email task?
cat filename | mailx -s "subject" abc#def.com
or
use mutt command to send files as attachments
At session level, in components tab we have option to send mail along with attachments.we have to provide path of the file as well using %a<> built in command.
Example:-
%a

How can I open multiple attachments of the same name in an email, then move the sender of the attachment to a spreadsheet?

I have an internship and was recently assigned the tedious task of cleaning the email lists. My employer has sent me a series of email with email bounces as attachments, many at a time, all with the same name. I have considered ways of doing this most efficiently, I'm looking to avoid just clicking through like a slave. My thoughts were to create a macro using autohotkey's language, but I feel like maybe a batch file or some sort of Perl might do the same thing. Could anybody give me an idea as to how to do this, specifically with a batch file? Thanks in advance!
Mail::DeliveryStatus::BounceParser parses bouncing email addresses out of delivery report messages.
If you don't know any perl, then I recommend that you first convert the mailbox into some format that stores each email in separate text files, like MH or similar.
At that point, you can trivially use the command grep _pattern_ | sed -e 's/:.*//' | sort | uniq > _list_ to obtain lists of all files matching _pattern_. You may inspect/edit this file _list_ to verify that the desired results were obtained.
You may then create another director junk or whatever and move all the files listed in _list_ into junk with a command like perl -e 'chomp; rename($_,"junk");' < _list_.
If you'll need this regularly, then you could automate this further, likely using perl alone, but a one off task will probably involve more messing about with getting the right message list.
Alternatively, you could load all the emails into a single folder in an sane mail reader, like Mac OS X's Mail.app, and do simply search, select all, move/delete commands.

Is there a difference between the Outlook .MSG and .OFT file formats?

This question is somewhat of a long shot, but I've spent hours on it to no avail. I have some code that generates an email file on a webserver, and allows the user to download that email and open it in Outlook. From here, they can make various manual changes to the email before they send it to a bunch of people.
Right now, I generate a .OFT file, which is basically an email template. What I want to do is generate a .MSG file, which is an actual email. From a binary point of view, it seems these file formats are identical. They have the same Stream IDs and properties and stuff.
My approach was to first create a blank email message in Outlook and then just save it to a file called Base.oft. In my code, I open the document and modify Stream ID __substg1.0_1013001E which is the ID for the HTML email body. I then save the file and write it out to the cilent. This works perfectly.
I tried the same approach with the MSG format. I created a blank email message, saved it as Base.msg, and modify the same Stream ID. If I look at the resulting file, the new body is actually in there and saved. However, if I open the email, the body is still blank.
What's even weirder is if I type in a body in Outlook and save that to the base file, I can see that body under stream 0_1013001E. If I then modify that stream with a different body, I can verify the new body is indeed saved in the file, but if I open the message in Outlook, I see the old, original body. It's as if the email body is stored in a different place in the file for the .MSG format, however I've looked through each stream and cannot find anything else that looks like it could be an email body.
Perhaps .MSG files are encrypted, or their bodies are stored in some proprietary binary format unlike .OFT files? Hopefully someone has some insight on this, as I scoured the Internet and found basically nothing on these formats.
Update:
It seems the .MSG format stores the body in Stream ID __substg1.0_10090102 - Which is encoded in some binary form (not sure what.) If I delete the stream (or set it to a single \0, the file becomes corrupt.
First of all, to find more information on this and related topics, move away from raw substream numbers and google for the corresponding MAPI properties. For example, 1013 is PR_HTML and 1009 is PR_RTF_COMPRESSED. MAPI has ways of synching the body from one format to the other.
See this article on MSDN for a good overview of all content-related MAPI properties (i.e. the different "streams" inside the .MSG file).
To write PR_RTF_COMPRESSED, wrap the stream inside WrapCompressedStream. On the other hand, in your particular situation you might want to avoid the MAPI-dependencies in your code, so maybe you're better off finding the PR_STORE_SUPPORT_MASK and setting the STORE_UNCOMPRESSED_RTF bit. This will allow you to use straight RTF in the PR_RTF_COMPRESSED substream. Or Outlooks fancy html-wrapped-in-rtf, if you are feeling brave.
None of this stuff is for the faint of heart, but seeing how you are already handing raw .MSG substream writing, I'm guessing it would be feasible.
When it comes to the format, there is no difference.
the only difference is that OFT files have CLSID_TemplateMessage ({0006F046-0000-0000-C000-000000000046}) as the storage class (WriteClassStg), while MSG files use CLSID_MailMessage ({00020D0B-0000-0000-C000-000000000046})