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

Free Support Forum - aspose.com

Subject contains new line and carriage return

Using the latest version of Aspose.Email 21.8.1 (.Net) we have encountered, for long subjects a carriage return linefeed is being placed in the string.

Actual Subject:
[eBook] Discover the Benefits of Making Payment Optimization a Part of Your Core Payment Strategy
Processed Subject:
[eBook] Discover the Benefits of Making Payment Optimization a Part \r\nof Your Core Payment Strategy

I have found a similar issue which had been resolved previously.

@Francis73,
Thank you for posting the query. Could you share the message file and code example reproducing the problem, please?

I have investigated this further and it appears the issue is the ImapClient.FetchMessage (https://apireference.aspose.com/email/net/aspose.email.clients.imap.imapclient/fetchmessage/methods/5) method.
Loading the message with the MailMessage.Load function returns the subject without the new line and carriage return characters.

I have included the code below and I have attached the sample message.
You will need to enter your details in the GetClient method and update the SelectFolder with a valid folder.

Please let me know if you require anything else to investigate.
message.zip (29.0 KB)

    static void Main(string[] args)
    {
        var g = new Aspose.Email.License();
        g.SetLicense("Aspose.Email.NET.lic");
        // Has carriage return and new line
        LoadViaImap();
        // Correct
        LoadMessage();
    }

    static void LoadViaImap()
    {
        using (var client = GetClient())
        {
            client.SelectFolder("AsposeTesting_Inbox");
            var messages = client.ListMessages();
            foreach (var messageInfo in messages)
            {
                var message = client.FetchMessage(messageInfo.UniqueId);
                var subject = message.Subject;
                Console.WriteLine(subject);
            }
        }
    }

    static ImapClient GetClient()
    {
        var client = new ImapClient
        {
            Host = "",
            Username = "",
            Password = "",
            Port = 993,
            SecurityOptions = Aspose.Email.Clients.SecurityOptions.SSLAuto
        };

        return client;
    }

    static void LoadMessage()
    {
        using (var message = Aspose.Email.MailMessage.Load(@"..\message.msg"))
        {
            var subject = message.Subject;
            Console.WriteLine(subject);
        }
    }

@Francis73,
Thank you for the additional information. I reproduced the problem with breaking the message subject into two lines and logged the issue with ID EMAILNET-40399 in our tracking system. Our development team will investigate this case. You will be notified when the problem is fixed.