Hi,
this is not the problem. The test source code above is for understand the problem. In our system the mail is saved on DB in this way:
client.SaveMessage(msg.UniqueId, $@"{messagePath}\{msg.UniqueId}.eml");
byte[] imapRawMessage;
MailMessage imapParsedMessage;
using (MemoryStream ms = new MemoryStream())
{
client.SaveMessage(msg.UniqueId, ms);
imapRawMessage = ms.ToArray();
imapParsedMessage = MailMessage.Load(ms);
}
//Controlla la presenza nell'intestazione del campo X-Ricevuta
if (string.IsNullOrEmpty(imapParsedMessage.Headers["X-Ricevuta"])) //Se il campo non è presente, allora si tratta di una mail
{
childLogger.LogPecController(taskID, $"Messaggio identificato come POSTA IN INGRESSO", LogControllerModelDirezioneEnum.Ricezione, mbx.Mailbox.ID, idMail);
//Genera il model della mail da salvare
MailModel mailToSave = childMailService.CreateModelFromEML(imapRawMessage);
mailToSave.DataRicezione = DateTime.Now;
mailToSave.ServerUniqueID = idMail;
//Imposta la cartella in cui salvarla
switch (mailToSave.EnumTipoMail)
{
case MailModelTipoMailEnum.Certificata: //Nel caso di posta certificata
childLogger.LogPecController(taskID, $"Messaggio di posta certificata", LogControllerModelDirezioneEnum.Ricezione, mbx.Mailbox.ID, idMail);
mailToSave.FolderID = childFolderService.GetFolderByRole(FolderModelRuoloEnum.Inbox).ID;
mailToSave.IsCertificata = true;
break;
case MailModelTipoMailEnum.NoCertificata: //Nel caso di posta non certificata
childLogger.LogPecController(taskID, $"Messaggio di posta non certificata", LogControllerModelDirezioneEnum.Ricezione, mbx.Mailbox.ID, idMail);
mailToSave.FolderID = childFolderService.GetFolderByRole(FolderModelRuoloEnum.NotCertified).ID;
mailToSave.IsCertificata = false;
break;
}
childMailService.Save(mailToSave);
newID = mailToSave.ID;
where class of “client” is Aspose.Email.Client.Imap.ImapClient.
The problem is that on the DB the name of the attachment is this:
“Comunicazione Cambio Indirizzo PEC Cilento Reti Gas_Societ? di Vendita.pdf”
Therefore the equality between the two strings is not verified.
We cannot change the EML, It seems that “Societ=EF=BF=BD” is not correctly converted into string.
The correct string should be “Società”, neither “Societ?” nor “Societ�”.
How can we convert correctly the char?
Thank you