Lotus Notes - 保存整个电子邮件消息eml c# [英] Lotus Notes - save whole email message eml c#

查看:469
本文介绍了Lotus Notes - 保存整个电子邮件消息eml c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要导出(保存到)硬盘驱动器我的Lotus Notes电子邮件。
我想出了如何将附件保存到硬盘驱动器的方式,但我无法弄清楚如何保存整个电子邮件。



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

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

命名空间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(); //数据库连接

//将包含文件夹名称的ArrayList
ArrayList LotusViews2 = new ArrayList();

foreach(在NDB.Views中的NotesView V)
{
if(V.IsFolder&&!(V.Name.Equals(($ All)) ))
{
NotesView getS = V;
LotusViews2.Add(getS.Name);
}
}

foreach(LotusViews2中的String obj)
{
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(AllDocItems中的对象CurItem)
{
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);
}
}
}
}
}


解决方案

Bob Babalan发表说明如何使用Java导出莲花文档。同样的原则应该在C#或VB中工作。该文档被转换为MIME并写入磁盘。



或在8.5.3版本中(我认为它起始于8.5.1),您只需拖放即可从邮件文件到文件系统。


I need to export (save to) hard drive my Lotus Notes emails. I figured out the way how to save attachments to HDD, but I can't figure out the way of how to save the whole email.

The code below shows how I export attachments. Can you suggest how can I modify it to save emails? PS- I am new to programming.

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

解决方案

This post by Bob Babalan explains how to export lotus documents using Java. The same principle should work in C# or VB. The document is cnverted into MIME and written to the disk.

Or in version 8.5.3 (I think it started witn 8.5.1) you can just drag and drop it from the mail file to the file system.

这篇关于Lotus Notes - 保存整个电子邮件消息eml c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆