Speichern Sie E-Mail-Nachricht als eml mit C# in Lotus Notes

Ich brauche zu exportieren (speichern) Festplatte meiner Lotus Notes-E-Mails.
Ich dachte, die Art und Weise, wie man Anhänge speichern auf HDD, aber ich kann nicht herausfinden, die Art, wie Sie die gesamte E-Mail.

Den code unten zeigt, wie ich die export-Anlagen. Können Sie empfehlen, wie kann ich es ändern, speichern E-Mails?
PS - ich bin neu in der Programmierung.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domino;
using System.Collections;

namespace ExportLotusAttachments
{
  class Class1
  {
    public void ScanForEmails()
    {
      String textBox1 = "c:\\1";
      NotesSession session = new NotesSession();
      session.Initialize("");
      NotesDbDirectory dir = null;
      dir = session.GetDbDirectory("");
      NotesDatabase db = null;
      db = dir.OpenMailDatabase();
      NotesDatabase NDb = dir.OpenMailDatabase(); //Database connection

      //ArrayList that will hold names of the folders
      ArrayList LotusViews2 = new ArrayList(); 

      foreach (NotesView V in NDb.Views)
      {
        if (V.IsFolder && !(V.Name.Equals("($All)")))
        {
          NotesView getS = V;
          LotusViews2.Add(getS.Name);
        }
      }

      foreach (String obj in LotusViews2)
      {
        NotesDocument NDoc;
        NotesView nInboxDocs = NDb.GetView(obj);
        NDoc = nInboxDocs.GetFirstDocument();
        String pAttachment;

        while (NDoc != null)
        {
          if (NDoc.HasEmbedded && NDoc.HasItem("$File"))
          {
            object[] AllDocItems = (object[])NDoc.Items;
            foreach (object CurItem in AllDocItems)
            {
              NotesItem nItem = (NotesItem)CurItem;
              if (IT_TYPE.ATTACHMENT == nItem.type)
              {
                String path = textBox1;
                pAttachment = ((object[])nItem.Values)[0].ToString();

                if (!System.IO.Directory.Exists(path))
                {
                  System.IO.Directory.CreateDirectory(textBox1);
                }

                try
                {
                  NDoc.GetAttachment(pAttachment).ExtractFile(@path + pAttachment);
                }
                catch { }
              }
            }
          }
          NDoc = nInboxDocs.GetNextDocument(NDoc);
        }
      }
    }
  }
}
  • Bitte eine Vorschau Ihrer code (Sie können dies durch die Suche unterhalb des Bereichs, den Sie eingeben es) für die Formatierung vor der Veröffentlichung. Es macht nicht nur Ihre Frage mehr lesbar, es spart Zeit, weil andere Leute nicht haben zu verbringen, die ihrigen zu fixieren. 🙂 Die es einfacher für Menschen zu Lesen und zu verstehen, desto wahrscheinlicher werden Sie eine Antwort bekommen. Danke.
InformationsquelleAutor Andrew | 2011-12-09
Schreibe einen Kommentar