Aspose Email Version: aspose-email-25.12-jdk16.jar licensed version. We are getting the below exception for email
class com.aspose.email.system.exceptions.FormatException: The string contains invalid characters
com.aspose.email.internal.b.zj.j(Unknown Source)
com.aspose.email.zci.a(SourceFile:123)
com.aspose.email.zci.(SourceFile:64)
com.aspose.email.zaxx$zb.a(SourceFile:34)
com.aspose.email.zaxx.a(SourceFile:1329)
com.aspose.email.zhm.a(SourceFile:232)
com.aspose.email.zhf.b(SourceFile:320)
com.aspose.email.zhf.a(SourceFile:259)
com.aspose.email.zaw.a(SourceFile:93)
com.aspose.email.MailMessage.b(SourceFile:5574)
com.aspose.email.MailMessage.f(SourceFile:4851)
com.aspose.email.MailMessage.a(SourceFile:4643)
com.aspose.email.MailMessage.a(SourceFile:4215)
@Janani009
You are encountering a FormatException with the message “The string contains invalid characters” while processing emails using Aspose.Email 25.12 . This aligns with previously reported issues involving malformed headers or content in email files .
A similar case was reported where the exception occurred due to invalid characters in header names, such as X-MS-Exchange-Organization-AVStamp-Enterprise: . Another user experienced a FormatException when loading MHTML files generated by Aspose Words, indicating the issue might stem from specific content or format types .
To help resolve this, you should identify which specific header or content is causing the issue. Try loading the email with MhtmlLoadOptions or inspect the raw headers manually to locate problematic entries . If the issue continues after reviewing the content, consider sharing a sample file and your code for further investigation .
A support engineer will follow up in this thread if needed.
Hello @Janani009 ,
Thank you for sharing the stack trace.
FormatException is usually caused by invalid or non-supported characters in one of the email fields (for example: Subject, From/To address, display name, headers, or body), or by an encoding mismatch.
To help us investigate further, could you please provide:
- A minimal reproducible code sample
- A sample input email that triggers the issue (you may delete sensitive data)