GroupDocs Merger not working with .msg files

I am splitting the files and on each page I am extracting text using GroupDocs Parser, now the problem is when I am trying to do the same with .msg file I am getting the error “Unsupported file Type”. below is my code

using (Merger merger = new Merger(mStream))
{
	// Extract the page to a MemoryStream
	using (MemoryStream pageStream = new MemoryStream())
	{
		merger.ExtractPages(extractOptions);
		merger.Save(pageStream);

		// Reset the stream position to the beginning
		pageStream.Seek(0, SeekOrigin.Begin);

		// Extract text from the page stream
		WriteLog.WriteToLog("Extracting text using GD ...");
		WriteLog.WriteToLog("Page " + pageIndex + " extracting");

		string strCurrentPage = string.Empty;

		try
		{
			strCurrentPage = ExtractTextAll(pageStream, false).Trim();
		}
		catch (Exception ex)
		{
			WriteLog.WriteToLog($"Error processing page {pageIndex}: {ex.Message}");
			strCurrentPage = "";
		}

		// Append the extracted text and insert into the database
		strTextData.Append(strCurrentPage);
		InsertSinglePage.InsertPageNum(pageIndex, strCurrentPage, fileVersionId);
	}
}

private string ExtractTextAll(MemoryStream stream, bool formatted)
{
	// Reset the stream position to the beginning
	stream.Seek(0, SeekOrigin.Begin);

	// Initialize the parser and text extraction
	using (var parser = new GroupDocs.Parser.Parser(stream))
	{
		// Extract text from the document
		var text = parser.GetText(new GroupDocs.Parser.Options.TextOptions(true));

		// Return the extracted text
		return text?.ReadToEnd();
	}
}

can we have any workaround here?

@Niteen_Jadhav

It appears you are encountering an “Unsupported file type” error when trying to work with .msg files using GroupDocs Merger. This issue arises because the GroupDocs Merger library does not support .msg files directly for merging or processing.

Solution:
To resolve this, you can use the GroupDocs Viewer as a workaround. The Viewer can convert .msg files to supported formats such as HTML, PDF, PNG, or JPEG, which you can then process further.

Next Steps:

  1. Render the .msg File: Use the GroupDocs Viewer to render the .msg file to a PDF. Here’s a basic example of how to do this:
using (Viewer viewer = new Viewer("path/to/your/file.msg"))
{
    PdfViewOptions options = new PdfViewOptions("output.pdf");
    viewer.View(options);
}
  1. Extract Text: After rendering the .msg file to a PDF, you can then load the generated PDF into your existing text extraction logic using the GroupDocs Parser.

  2. Check Supported Formats: Always verify that the file types you are working with are supported by the specific GroupDocs library you are using. Refer to the documentation for a list of supported formats.

If you have any further questions or need additional assistance, please let me know!