I have investigated this further and it appears the issue is the ImapClient.FetchMessage (https://reference.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);
}
}