How to Get Folder information From NSF File

How to get View/Folder Information from NSF File. (Location of the message in NSF File).

@hemalp

To retrieve folder or view information from an NSF file using Aspose.Email, you can utilize the NotesStorageFacility class. This class allows you to access and enumerate messages stored in the NSF file. Below is an example of how to implement this in C# and Java.

C# Example

using Aspose.Email.Storage.Nsf;
using System;

namespace Aspose.Email.Examples.CSharp.Email
{
    class ReadMessagesFromNSFStorage
    {
        public static void Run()
        {
            // Specify the path to the NSF file
            string dataDir = "path_to_your_nsf_file/SampleNSF.nsf";

            using (NotesStorageFacility nsf = new NotesStorageFacility(dataDir))
            {
                // Enumerate through messages in the NSF file
                foreach (MailMessage eml in nsf.EnumerateMessages())
                {
                    Console.WriteLine(eml.Subject); // Print the subject of each message
                }
            }
        }
    }
}

Java Example

package com.aspose.email.examples.email;

import com.aspose.email.MailMessage;
import com.aspose.email.NotesStorageFacility;
import com.aspose.email.examples.Utils;

public class ReadMessagesFromNSFStorage {

    public static void main(String[] args) {
        // Specify the path to the NSF file
        String dataDir = Utils.getSharedDataDir(ReadMessagesFromNSFStorage.class) + "email/";

        NotesStorageFacility nsf = new NotesStorageFacility(dataDir + "SampleNSF.nsf");
        try {
            // Enumerate through messages in the NSF file
            for (MailMessage eml : nsf.enumerateMessages()) {
                System.out.println(eml.getSubject()); // Print the subject of each message
            }
        } finally {
            nsf.dispose(); // Ensure resources are released
        }
    }
}

In both examples, replace "path_to_your_nsf_file/SampleNSF.nsf" with the actual path to your NSF file. The code will print the subject of each message found in the NSF file, which can help you identify the location of messages within the file.

For more detailed information, you can refer to the official documentation or the examples provided in the Aspose.Email GitHub repository.

Sources:
[1]: ReadMessagesFromNSFStorage.cs
[2]: ReadMessagesFromNSFStorage.java

Can you please provide property name which have information of Folder. For Example Inbox,SentItem

Hello @hemalp,

Unfortunately, only message reading is supported. Folder reading is not available due to the lack of specifications.

Additionally, we want to inform you that the overall implementation of NSF is quite limited. In general, you may encounter issues in the following cases:

  • The file was created using Notes version 7 or higher
  • LZ1 compression is used

We apologize for any inconvenience caused.