I have a .NET Windows service that sends emails using MimeKit. It creates a BodyBuilder and attaches a PDF file:
builder.Attachments.Add(fileName);
Where 'fileName' is the full path and filename of a PDF file. The file exists, it's 300KB, the service can access it. When I test locally with the file in question the Add() is almost instant. On the customer's server with the deployed service, it takes 20 seconds to add the attachment, meaning that the server that the SmtpClient instance is connected to times out waiting for some action after the connect and auth has happened.
What could cause this huge difference in attaching a small file between dev machine and server?
There are a few possibilities:
builder.Attachments.Add() loads the file into a MemoryBlockStream internally, so both of those could be a factor.