Asp.net sending email with zip file as attachment

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.

In above example Zip.save(memoryStreamOfFile) save the zip file to memorystream format and later memoryStreamOfFile used for email attachment.

Download the full .net c# source code here

You can check my previous articles on sending email and file compression

  1. How to send the email using godaddy hosting account (http://www.cmsstores.com/asp-net-sending-email-using-godaddy-hosting-account//)
  2. Asp.net file compression technique(http://www.cmsstores.com/asp-net-file-compression-using-opensource-librar//)
Get me a cup of Coffee
to write in right spirit
3USD


Similar Topics:

Tags:

bravepiz
We will send you more information on Asp.net sending email with zip file as attachment.
Enter your email address:
This entry was posted in .Net and tagged . Bookmark the permalink.

2 Responses to Asp.net sending email with zip file as attachment

  1. Federico says:

    hey when i receive the email with the attachment , it has a “.dat” extension.

    is there any way to set the contenttype of the memorystream?

  2. Federico says:

    problem solved! i just write the .zip in attachment name!

Leave a Reply

Your email address will not be published. Required fields are marked *