Forward message without loading


Is it possible to forward a message without opening it first with MailMessage? It sometimes raises out of memory exception for us.



Yes, this is possible using the SmtpClient of the API. Please have a look at the following code sample for your reference. The same is available in Aspose.Email documentation.

Sample Code

string host = "";
string username = "username";
string password = "password";
int smtpPort = 587;
string sender = "";
MailAddressCollection recipients = new MailAddressCollection();

using (SmtpClient client = new SmtpClient(host, smtpPort, username, password, SecurityOptions.Auto))
    string fileName = @"test.eml";
    using (FileStream fs = File.OpenRead(dataDir + fileName))
        client.Forward(sender, recipients, fs);