We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Forwarding message without loading EML file using MailMessage

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.

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.


Hi Alex,

Thank you for posting your inquiry.

Could you please share with us if you require this sort of facility for SMTP or EWS Client? In case of EWS, you may consider using:

void Forward(MailMessage message, ExchangeMessageInfo referencedMessage);

that uses the source message summary info only to create and forward a message.

At present, our API must has to load the message (from disc or stream) and convert it to EML before sending using SMTP. So, it seems somewhat difficult to implement the requirement as you have suggested. Please feel free to share your further thoughts with us for further consideration in this regard.
Hi, Kashif Iqbal

Initial post already contains answer for your question :).

Could you please share with us if you require this sort of facility for SMTP or EWS Client?

As stated before, I use SmtpClient in order to send messages to a smart host via SMTP protocol.

At present, our API must has to load the message (from disc or stream) and convert it to EML before sending using SMTP.

I use SmtpClient to send EML messages. Messages are already in EML format and remote server will accept them and successfully read - no need to convert message to EML.

The only concern is how to organize data transmission after DATA command (see SMTP specification). If it is OK just to read file line-by-line and send it via TCP connection, then it is what I need. And that is where I need thoughts of your SmtpClinet developers.

In simple words, I need method like SmtpClient.ForwardEml(from, recipients, path|stream) that does not load MailMessage object from file or stream, because method assumes that file is already in EML format and file content may be sent to the remote server after DATA command.


Hi Alex,

We have shared these details with our Product team for any such possible implementation and will update you here as soon as some information is available in this regard.

Thanks, Kashif Iqbal.

Look forward to hearing back from development team.


Sure, you will be notified immediately once the feedback is available.


Want to share information why this is an important for me.

As I already mentioned in other ticket MailMessage class is really heavy. It may consume 300 MB of RAM to read 86MB EML file (link). This is already not very good scenario for 32 bit application.

But things are getting even worse when you try to send this big message using SmtpClient. I need to read EML file (will eat 200), then use Forward method, that will eat additional 400MB of RAM - that is twice as much as required to load message from stream. Most certainly you will receive OutOfMemory in a “large” process, that process many messages.


Also I was reported about the issue, when message was successfully accepted by the the smart host and SmtpClient.Forward method thrown OutOfMemory exception afterwards. My application tried to send message again and again, getting OutOfMemory each time. In result message was delivered 8 times.

Seams OutOfMemory happened after the point when smart host excepted message (after DATA command).


Hi Alex,

We regret the inconvenience caused to you.

As mentioned earlier in another thread, we are in process of refactoring the implementation of MailMessage for improved performance and to avoid OutOfMemory issues. Your request of Forwarding message without loading in MailMessage is already logged as EMAILNET-38696 and is linked with this thread. Once there is further information available about the status of this request, we’ll update you here via this thread.

The issues you have found earlier (filed as EMAILNET-38696) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.