Scenario: Part of my logic is responsible for sending EML messages to the smart host. I use SmtpClient.Forward method.
Concern: For each delivery job I have to load EML file using MailMessage class and use message object in Forward method. But reading EML file means that additional memory is allocated.
Thoughts
The idea is to send EML file without reading it. SmtpClient already provides method that takes addresses of sender and intended recipients as parameters to use with MAIL FROM and RCPT commands in SMTP dialog. But now Forward method requires instance of MailMessage class.
As I understand message content is sent with DATA command. So, theoretically, it is possible to read EML file line-by-line and send it to smart host without reading MailMessage object after DATA command.
In other words, create new Forward method, that takes addresses of a sender and intended recipients and file path (or stream). Use specified addresses in MAIL FROM and RCPT commands and then send message content directly from file (stream) in chunks (line-by-line) after DATA command.
Does it make sense? Please share your thoughts.
Thanks,
Alex