+1 vote

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

by

1 Answer

0 votes
 
Best answer

You can use the SIZE extension, if it is available.

It gets the maximum size of the email message in bytes that SMTP client can send:

using (Smtp client = new Smtp())
{
    client.Connect("smtp.example.com);
    client.UseBestLogin("user@example.com", "password");

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

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

    long? messageSizeInBytes = size.Value;

    client.Close();
}
by (297k points)
...