Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET) platform with fast and high quality performance.

Fri Sep 23, 2022 7:39 pm

Hi! I was using Aspose Email to process PST messages, but found that there is a 50 message limit for the free version. As I am just a person and not a company, I'm NOT paying $1000 for Aspose, lol. So I Googled and found Spire.Email. Works great for reading, but I'm perplexed as to editing/deleting.

The use case is I am a developer that makes Minecraft plugins for people. I tell them if they have issues to use a webform I made. The form emails a special email, and I have an Outlook rule that moves those emails to a PST. What I do is run a C# program I wrote that parses the PST and when I mark the issue as resolved, it edits the message subject and does "[DONE] " + subject so the next time I open it and scan, it won't display that.

So what I'm confused about is, how do I edit the record to update the message subject? If I can't, I saw the OutlookFolder object has a RemoveItem method. I am fine with just deleting the messages from the folder if needs be, but I can't find the entry ID byte[] to pass to it. When I read I'm doing:
Code: Select all
public static List<SupportQuestion> GetSupportQuestion(string pstfile) {
  try {
    if (!File.Exists(pstfile)) {
      Dialog("Invalid PST file!");
      return new List<SupportQuestion>();
    }

    List<SupportQuestion> records = new List<SupportQuestion>();
    OutlookFile outlookFile = new OutlookFile(pstfile);
    OutlookFolder folder = outlookFile.GetFolder("Questions");
    IEnumerable<OutlookItem> items = folder.EnumerateOutlookItem();
    foreach (var item in items) {
      // I use the data from item here to create a SupportQuestion object and add to the list
    }
    return records;
  } catch (Exception ex) {
    Dialog("** Exception during GetSupportQuestion:\n\n" + ex.Message);
    return new List<SupportQuestion>();
  }
}

In the loop if I do item. and read the available properties, I don't see anything that sounds right.

Can someone clarify? Ideally on how to edit a subject, but failing that how to get the entry ID for a messaging whilst looping the enumerated Outlook items as I am.

Thanks a lot!

Sylvaran
 
Posts: 7
Joined: Fri Sep 23, 2022 7:29 pm

Mon Sep 26, 2022 10:08 am

Hello,

Thanks for your inquiry.
Sorry that there is currently no way to directly modify the subject of email in *.pst file and remove the mail from *.pst file. However, I suggest you create a new folder and then add mails to the new folder to meet your needs, this will add a new folder to your original *.pst file and add all the emails that have changed the subject to the new folder. I put the complete code below for your reference.
If you have any issue, just feel free to contact us.

Code: Select all
  public static List<SupportQuestion> GetSupportQuestion(string pstfile)
            {
                try
                {
                    if (!File.Exists(pstfile))
                    {
                        Dialog("Invalid PST file!");
                        return new List<SupportQuestion>();
                    }

                    List<SupportQuestion> records = new List<SupportQuestion>();
                    OutlookFile outlookFile = new OutlookFile(pstfile);
                    OutlookFolder folder = outlookFile.GetFolder("Questions");
                    IEnumerable<OutlookItem> items = folder.EnumerateOutlookItem();

                    OutlookFolder NewFolder = outlookFile.RootOutlookFolder.AddFolder("NewFolder");
                    foreach (var item in items)
                    {
                        item.Subject = "[DONE] " + item.Subject;
                        NewFolder.AddItem(item);
                    }
                    return records;
                }
                catch (Exception ex)
                {
                    Dialog("** Exception during GetSupportQuestion:\n\n" + ex.Message);
                    return new List<SupportQuestion>();
                }


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Sat Oct 01, 2022 4:44 pm

Awesome! Moving them is perfectly acceptable as well. I appreciate the help :)

Sylvaran
 
Posts: 7
Joined: Fri Sep 23, 2022 7:29 pm

Mon Oct 03, 2022 1:44 am

Hello,

Thanks for your feedback.
If you have any issue in the future, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Email