Free Support Forum - groupdocs.com

Difficulty viewing .msg files


#1
I've converted to the 3.1 version of the GroupDocs viewer. I'm using HTML previews. In general I'm getting good results, but not with .msg files. Consistently they don't show embedded images or attachments. In the latest release notes I see the following:

- Email document loading by passing load options.
- Add required html markup for email documents.

I haven't found any new options that I can configure that relate to any new capabilities.

With the 2.x viewer msg files were handled fine. What do I need to do with the new viewer?
Thanks,
Don

#2

Hi Dwaldo,


Thank you for your inquiry.

Obviously, the .msg files format is in the list of supported format of Groupdocs.Viewer 3.x.
Therefore, we are interested to know that how the issue is being generated at your side.

I would like to request you to provide us as written in below points.
  • Problematic file
  • The project source code(if possible).
  • Browser information

Have a nice day!

#3

The issues you have found earlier (filed as VIEWERNET-550) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by groupdocs.notifier.

#4
I've tried with a handful of msg files and had similar problems with all of them. I'm attaching the most recent one I worked with.

The full source code is not practical to deliver, but the core object/method I'm calling is ViewerHtmlHandler.GetPages(stream, folderName, HtmlOptions).

For the HTML options I'm setting IsResourcesEmbedded=false and HtmlResourcePrefix="res/". Other values are whatever their defaults are.

Once that call completes I see a page1.html generated in the correct location. It has a resources folder with an empty "page1" sub-folder.

I don't think the browser version is relevant because the HTML that is generated by the GetPages call has nothing that describes the existence of an attachment, and the image embedded in the msg is not saved as a resource.

Let me know if you need more information.
Thanks,
Don

#5
I've upgraded to 3.3 and see much improvement in the handling of MSG files, but still have problems get HTML pages rendered from attachments. I've tried 4 msg files with attachments and have problems with all but one of them. In each case I've successfully viewed the document when it was not an attachment.

The error occurs during the GetPages call in this loop:
foreach (AttachmentBase attachment in docInfo.Attachments)
try
{
viewerHandler.GetPages(attachment, opt);
}
catch (Exception ex)
{
app.LogMsg("DocumentViewer attachment exception on " + attachment.SourceDocumentGuid + " - " + attachment.Name, "ERROR");
app.LogMsg(ex.Message + "
" + ex.StackTrace, "ERROR");
}

I get two different kinds of stack traces depending on whether the attachment is an xlsx file or a docx file. For XLSX the stack looks like this:

Object reference not set to an instance of an object.
()
at .
(FileDataOptions )
at .(FileDataOptions )
at GroupDocs.Viewer.Handler.ViewerHandler`1.GetFileData(ViewerConfig viewerConfig, IInputDataHandler inputDataHandler, ICacheDataHandler cacheDataHandler, ILocalizationHandler localizationHandler, FileDescription fileDescription, ConverterOptions converterOptions)
at GroupDocs.Viewer.Handler.ViewerHandler`1.(ConvertOptions , ConverterOptions )
at GroupDocs.Viewer.Handler.ViewerHandler`1.GetPages(Stream fileStream, String fileName, ConverterOptions converterOptions)
at GroupDocs.Viewer.Handler.ViewerHandler`1.GetPages(AttachmentBase attachment, ConverterOptions converterOptions)
at GroupDocs.Viewer.Handler.ViewerHtmlHandler.GetPages(AttachmentBase attachment, HtmlOptions htmlOptions)
at Handshake.GroupDocs.CacheManagement.ThreadStart_UpdateDocumentCache(Object args) in C:\TFS Projects\Active\Unreleased\Server\HandshakeWebServices\Handshake.GroupDocs\CacheManagement.cs:line 259


For a DOCX file the stack trace is:

File type 'docx' is not supported.
at
at
at
at .(FileDataOptions )
at .(FileDataOptions )
at GroupDocs.Viewer.Handler.ViewerHandler`1.GetFileData(ViewerConfig viewerConfig, IInputDataHandler inputDataHandler, ICacheDataHandler cacheDataHandler, ILocalizationHandler localizationHandler, FileDescription fileDescription, ConverterOptions converterOptions)
at GroupDocs.Viewer.Handler.ViewerHandler`1.(ConvertOptions , ConverterOptions )
at GroupDocs.Viewer.Handler.ViewerHandler`1.GetPages(Stream fileStream, String fileName, ConverterOptions converterOptions)
at GroupDocs.Viewer.Handler.ViewerHandler`1.GetPages(AttachmentBase attachment, ConverterOptions converterOptions)
at GroupDocs.Viewer.Handler.ViewerHtmlHandler.GetPages(AttachmentBase attachment, HtmlOptions htmlOptions)
at Handshake.GroupDocs.CacheManagement.ThreadStart_UpdateDocumentCache(Object args) in C:\TFS Projects\Active\Unreleased\Server\HandshakeWebServices\Handshake.GroupDocs\CacheManagement.cs:line 259

Again, the DOCX file that was attached to the email works fine if I render it from a DOCX instead of within an MSG.

I've uploaded a zip file with 3 messages that demonstrate the problem.

Thanks,
Don

#6

Hi Don,


Thank you for your response.

Your issue has been identified and we have created a bug ticket in our issue tracking system. Our product team will look into this issue. Once there is any further update, you will be updated via this forum thread.


Please stay tuned!

#7

Hi Don,


We apologize for inconvenience.

We are investigating your issue and shall get back to you shortly. Please stay with us.


Thanks for cooperation.

Warm Regards

#8

Hi Don,


Thanks for the patience.

Unfortunately, we could not reproduce your stated issue at our end. We will need some more information from you to figure it out. Please provide us the code where you are setting the storage path. Also, please tell us whether you are testing this feature in our example project hosted on Github or you are using it in your own project.

We will wait for your response.

Warm Regards

#9
The testing was done in my project. The code for setting the storage path looks like this:
private static ViewerConfig GetViewerConfig()
{
ViewerConfig config = new ViewerConfig();
config.UseCache = true;
config.UsePdf = false;
string loc = GetCacheBaseLocation();
config.StoragePath = loc + "\\Temp";
config.TempFolderName = loc + "\\Temp";
config.CacheFolderName = loc + "\\Cache";
config.CachePath = loc + "\\Cache";
return config;
}

In my testing GetCacheBaseLocation() is returning "C:\TFS Projects\Active\Unreleased\Server\HandshakeWebServices\ViewerCache".

For everything other than MSG files it's working properly. For one of the four MSG files it appears to work. For all MSG files the main document preview is generated. The error is always related to attachments.

Does your response mean that the files I uploaded are generating good previews in your testing?

In my testing, even for the working MSG file the attachment doesn't generate information about page count in my call to GetDocumentInfo.
Thanks,
Don

#10

Hi Don,


Thanks for providing more details.

I have tested the API with the configuration same as yours but didn’t get any issue in rendering the attachments. Have you tested this feature in the GroupDocs.Viewer Examples Project provided on Github? If not, please download and try your .msg files in that. Also, if possible, please provide us your application project so that we can test it to find out what is the reason behind the issue you are facing.

We will be waiting for your response.


Best Regards

#11
It looks like the MSG files are working with your example app. I've been trying variations in my code to make it conform more to the structure of the sample app. From what I've learned it looks like my problem is caused by my implementation of a custom InputDataHandler. I'll attach my IInputDataHandler implementation so you can see if it's got an obvious problem. I don't know why the problem only appears for these files.

I think I can do without my InputDataHandler if I always download a local copy of the document.


#12

Hi Don,


Thanks for providing us the information.

There can be issue with the path while saving the attachments from the MSG file. Please debug your project and check if the attachment files are saved in the storage location where they are supposed to be. Also, please check whether some invalid path exception occurs during GetPages() function or not. Please try and share your experience.

We will be waiting for your response.


Warm Regards

#13
I don't think that was the problem. I saw the attachments saved in the correct location and the exceptions that occurred didn't include a path exception. At this point I've removed my custom input handler and instead I just write a copy of the file to the GroupDocs temp folder.

On a related note, when do files in the temp folder get deleted? I've written code to manage the cache, but I don't know if I also need to purge the temp folder in my code.

Thanks,
Don

#14

Hi Don,


Its good that you figured out the solution.

To remove the cache files, GroupDocs.Viewer for .NET provides ClearCache() method in v3.3.0. Please visit this link to know more about this feature.

Please note that the API uses temp folder as default cache folder if you do not set CachePath in configuration. In this case ClearCache() will clean temp folder. Whereas, if you have set the CachePath i-e CachePath= “D:/ViewerCache/Cache”, then ClearCache() will clean D:/ViewerCache/Cache folder.

If you have any further questions, please let us know.


Warm Regards

#15
In my case I'm setting both the temp and cache folders in ViewerConfig. I can't tell from the documentation how GroupDocs handles them. My code for setting the ViewerConfig looks like this:
ViewerConfig config = new ViewerConfig();
config.UseCache = true;
config.UsePdf = false;
string loc = GetCacheBaseLocation();
config.StoragePath = loc + "\\Temp";
config.TempFolderName = loc + "\\Temp";
config.CacheFolderName = loc + "\\Cache";
config.CachePath = loc + "\\Cache";

When my code runs I see the same folders created in the Cache and Temp folders under the root. In the Cache folder I see all of the renderings that get generated as well as other content that my code writes there. In the Temp folder I see the same subfolders as in Cache. In each folder I see a file called fd.xml. I don't know what operation is creating those folders and files and when it is safe to remove them.

My questions are:
1. Is there a better way to set up ViewerConfig than what I'm doing?
2. In this configuration what is GroupDocs writing to Temp and when can it be deleted?
3. Does GroupDocs automatically remove the files it creates in the Temp folder?

Thanks,
Don

#16

Hi Don,


Thanks for posting detailed information.

I am writing inline answers of your questions.

1. Is there a better way to set up ViewerConfig than what I’m doing?
The better way is to use StoragePath only and let the API use temp folder as default cache directory. In this case, ClearCache() function will remove all the cached files including fd.xml file which is generated by API and there will be no need to remove contents of temp folder separately.

2. In this configuration what is GroupDocs writing to Temp and when can it be deleted?
The API creates fd.xml file in temp folder that contains file data (i-e page data, page count, creation date etc.). The file can be deleted after the document is rendered.

3. Does GroupDocs automatically remove the files it creates in the Temp folder?
The API does not remove files in temp folder automatically. You will have to remove them manually or programatically. Again, if you use temp folder as default cache directory then ClearCache() function can fulfill your requirements.

You can also use your custom logic to clean temp folder on different conditions i-e when the folder size reaches 20Mb etc.


If you have any further questions, please let us know.


Warm Regards