I have to zip files and then send them as attachment via email. For this i zip a folder, save it and

Posted by Sp under ASP.NET on 12/9/2010 | Points: 10 | Views : 2351 | Status : [Member] | Replies : 2
I have to zip files and then send them as attachment via email.
For this i zip a folder, save it and then use it as attachment via email..
But theses zip files are consuming extra space on my system.
If i try to delete the file soon after the email is sent then i get an error that the file is being used by some other process. How to delete these zip files...




Responses

Posted by: Raja on: 12/9/2010 [Member] Starter | Points: 25

Up
0
Down
The error "that the file is being used by some other process. How to delete these zip files.." you are getting is to do with the object that is being used to send the email.

Make sure that you are disposing your objects after the email is being sent. Use yourobject.Dispose() or yourobject.Close() methods and you should be able to delete the file.

Thanks

Regards,
Raja, USA

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chiragkanzariya on: 11/29/2012 [Member] Starter | Points: 25

Up
0
Down
Hi ,

In this article I would like to explain how to send the compressed or zip document as an email attachments. You can find the c# source code sample how to send the email with zip format. If you are sending the html attachment or some JavaScript there might be change attachment get corrupted. If you are using the outlook web access (OWA) email client to read the email, there might be change of your html get corrupted because of OWA html filtering option.

Best solution is we can compress the file and attach to email as attachment. We can find the different approachs to send the email, You can find the below best solution for attachment format.


Sending attachment as PDF format: You can use ItextSharp library to create the pdf file. You will get the lot of example on how to use the ItextSharp to create the pdf file on .net. I have plan to write one artical on creating the pdf using .net source code.

Sending attachment as zip: You can use opensource library to compress the file and send it as email. Visit my previous article asp.net file compression

Here I have used C# source code to send the email as attachment. Again I have used opensource DotNetZIP library as compression tool to compress the attachment before sending the email.

You can see full solution on my blog .http://chiragkanzariya.blogspot.in/2012/10/aspnet-sending-email-with-zip-file-as.html

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response