Skip to content
January 7, 2010 / kiranpatils

Exceeded storage allocation. The server response was: 5.7.0 Our system detected an illegal attachment on your message.

If you are genearting zip file runtime in memory and sending mail at run time. and you faced the error as shown below:

Exceeded storage allocation. The server response was: 5.7.0 Our system detected an illegal attachment on your message.

Then to fix it, you have to do the following change in your code(Pls note I’ve used SharpZipLib and Memory Stream for sending an email at run time using gmail server):

MemoryStream zipFileStream = new MemoryStream();
zipOutputStream = new ZipOutputStream(zipFileStream);
..
..
..
//read from stream and add to zipoutputstream code should go here
...
..
// Seek to begining -- IF YOU DON' ADD BELOW LINE IT Will give above error
zipFileStream.Seek(0, SeekOrigin.Begin);
mailMessage.Attachments.Add(new Attachment(zipFileStream, "myzipfile.zip"));

if you’ve seen the above code. Below line says MemroyStream to seek to Begining of the stream, So when SMTP Server scans the file before sending it gets perfect file.

zipFileStream.Seek(0, SeekOrigin.Begin);

Happy Mailing!


4 Comments

Leave a Comment
  1. Aakash / Apr 8 2010 12:00 pm

    Hi kiran,

    I am sending mail from SQL server 2005 and I’m getting same error there.

    Any idea about this scenario?

    Thanks

    Aakash

    • kiranpatils / Apr 12 2010 5:33 am

      Hi Aakash,

      Can you post your script here?

      Thanks,
      Kiran Patil

  2. Rinku Sharma / Jul 30 2012 11:00 am

    if u upload file on internet and this error occur…….
    it mean your file extension not support………….

Trackbacks

  1. sales process

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: