locked
how we can know the size of one e-mail? RRS feed

  • Question

  • I made one program that can send e-mail using system.net.mail library.

    The problem is that almost all the smtp servers they have a limit about how big the e-mail can be.

    And a lot of time this limit is at 10Mb.

    How can i check the size of e-mail message with code before i sended.

    Unfortuanally i cant use for this the size of the attachments because the size of the e-mail usually is around 2mb larger than the size of the files you attach at the e-mail.

    Monday, December 12, 2011 4:16 PM

Answers

  • Yes, that is based on how the attachments are encoded usually using either BASE64 ( increase the size about 35 % ) or QUOTEDPRINTABLE ( increase the size between 3% and 200 % ). So to examine the size of the mail you would need to first encode it into e.g. BASE64 and compute the size.
    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by chris_nikol Tuesday, December 13, 2011 1:34 PM
    Tuesday, December 13, 2011 10:44 AM

All replies

  • Chris,

    a email without attachments haave a size of about 2-5 kilobytes. So using the size of the attachments will be the way to go.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Tuesday, December 13, 2011 7:13 AM
  • Yes, but when you are sending attachment the things changing.

    Per example attachment with size 6.1 Mb produce e-mail with size 8.6Mb

    attachment with size 6.9 Mb produce e-mail with size 9.7Mb

    And because i wonder if this happened because of my application, i try to send e-mail with attachment using as a client thw windows live mail and the results was similar.

     

     

    Tuesday, December 13, 2011 10:21 AM
  • Yes, that is based on how the attachments are encoded usually using either BASE64 ( increase the size about 35 % ) or QUOTEDPRINTABLE ( increase the size between 3% and 200 % ). So to examine the size of the mail you would need to first encode it into e.g. BASE64 and compute the size.
    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by chris_nikol Tuesday, December 13, 2011 1:34 PM
    Tuesday, December 13, 2011 10:44 AM