c# - 在 Lotus Notes 中使用 C# 将电子邮件消息另存为 eml

标签 c# export lotus-notes eml

我需要将我的 Lotus Notes 电子邮件导出(保存到)硬盘。 我想出了如何将附件保存到硬盘的方法,但我想不出如何保存整个电子邮件的方法。

下面的代码显示了我如何导出附件。你能建议我如何修改它来保存电子邮件吗? PS-我是编程新手。

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);
        }
      }
    }
  }
}

最佳答案

ThisBob Babalan 发表说明如何使用 Java 导出 Lotus 文档。同样的原则应该适用于 C# 或 VB。文档被转换为MIME并写入磁盘。

或者在版本 8.5.3 中(我认为它是从 8.5.1 开始的)您可以将它从邮件文件拖放到文件系统中。

关于c# - 在 Lotus Notes 中使用 C# 将电子邮件消息另存为 eml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8452468/

相关文章:

lotus-notes - 我需要 View 中两列的总和

sql - Lotus DB 到 SQL Server 的迁移

java - 使用 Java api 按日期搜索 Lotus Notes

php - 目前我的代码将数据导出到 CSV 文件,并将其存储在服务器上。但我想让它下载文件。我该怎么做呢?

c# - 同类代码文件修改后生成T4文件

C# databound ComboBox 更改其他控件中的数据

c# - 命令行 MSBuild 无法编译代码

mysql - 如何从远程主机获取制表符分隔的 MySQL 转储?

javascript - YII2 Kartik - ExportMenu 仅导出选中项目的数据

c# - 将 MySQL double 导入到 C# 时出现 InvalidCastException