+1 vote

There any way to get the attachment limit imposed by a SMTP provider?


1 Answer

0 votes
Best answer

There aren't attachments limit really. However most servers limit the maximum size of the message.

You can use the SIZE extension if it is available:

using (Smtp client = new Smtp())
    client.UseBestLogin(user, password);

    List<SmtpExtension> list = client.SupportedExtensions();

    SmtpSizeExtension size = (SmtpSizeExtension)list
        .Find(x => x == SmtpExtension.Size);

    Assert.AreEqual("SIZE", size.Name);
    Assert.AreEqual(35882577, size.Value); // in bytes


The value returned is a maximum message size in octets. This number includes the message header, body, and the CR-LF sequences between lines.

You can use IMail.EstimateTransportSize() to estimate the size of your message.

by (298k points)