1

我正在尝试从“$File”(Lotus Notes)中访问附件名称。

 NotesView inbox = _serverDatabase.GetView("($Inbox)");
 NotesDocument docInbox = inbox.GetFirstDocument(); 

 NotesItem file = docInbox.GetFirstItem("$File");

 String fileType = file.type.ToString(); 

(获取包含附件的邮件的文件类型值“附件”)

我没有得到解决方案:

如何从 Notes 邮件中访问附件?

我得到了解决方案:

object[] items = (object[])docInbox.Items; 

foreach (NotesItem nItem in items)

{

  if (nItem.Name == "$FILE")
   {

     NotesItem file = docInbox.GetFirstItem("$File");   

     string fileName = ((object[])nItem.Values) [0].ToString();

     NotesEmbeddedObject attachfile = (NotesEmbeddedObject)docInbox.GetAttachment(fileName);

     if (attachfile != null)
      {
        attachfile.ExtractFile("C:\\test\\" + fileName);
      }
 } 

但在这里我只得到第一个附件值。谁能帮我解决这个问题?

4

2 回答 2

3

尝试这样的事情:

    NotesView inbox = _serverDatabase.GetView("($Inbox)"); 
    NotesDocument docInbox = inbox.GetFirstDocument();  
    if(docInbox.HasEmbedded )   {
       foreach (NotesEmbeddedObject o in docInbox.EmbeddedObjects) {
           if ( o.Type == 1454 ) {
            o.ExtractFile( "c:\samples\" & o.Source )    
    }
   }
}

这是 Lotus Notes Designer 帮助的链接 - 非常好,因为您可以搜索 Classes 等以找出您有哪些选项。

http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.help.domino.designer85.doc/DOC/H_WHAT_S_NEW_IN_RNEXT_CHAP.html

向您展示各种类的所有方法和属性。


嗨,普瑞蒂,

可以从另一个代码示例中返回一个数组:

string fileName = ((object[])nItem.Values) [0].ToString();

然而,您只选择第一个值,您需要通过集合递归。

尝试这样的事情。

foreach (object attachment in (object[])nItem.Values)
        {
            NotesEmbeddedObject attachfile = (NotesEmbeddedObject)docInbox.GetAttachment(attachment.ToString());

            if (attachfile != null)
            {
                attachfile.ExtractFile("C:\\test\\" + attachment.ToString());
            }

        }

乔什

于 2009-09-16T10:55:43.520 回答
0

您上面的代码片段对我很有帮助。因此,我尝试保存所有附件,最终找到了以下解决方案。

            NotesView nInboxDocs = NDb.GetView("$Inbox");
            NDoc=nInboxDocs.GetFirstDocument();
            while (NDoc != null)
            {
                if (NDoc.HasEmbedded && NDoc.HasItem("$File"))
                {
                    // To save only first attachment //
                    //pAttachment = ((object[])NDoc.GetItemValue("$File"))[0].ToString();
                    //pAttachment = CurItem.ToString();
                    //NDoc.GetAttachment(pAttachment).ExtractFile(@"C:\Documents and Settings\Administrator\Desktop\" + pAttachment);

                    // To save all attachment //
                    object[] AllDocItems = (object[])NDoc.Items;
                    foreach (object CurItem in AllDocItems)
                    {
                        NotesItem nItem = (NotesItem)CurItem;
                        if (IT_TYPE.ATTACHMENT == nItem.type)
                        {
                            pAttachment = ((object[])nItem.Values)[0].ToString();
                            NDoc.GetAttachment(pAttachment).ExtractFile(@"C:\Documents and Settings\Administrator\Desktop\" + pAttachment);
                        }
                    }
                }
                NDoc = nInboxDocs.GetNextDocument(NDoc);
            }
于 2009-09-23T07:40:53.273 回答