powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / Сохранение вложенных файлов из писем IBM Notes на C#
2 сообщений из 2, страница 1 из 1
Сохранение вложенных файлов из писем IBM Notes на C#
    #39509332
msleg
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Написал функцию на C# для загрузки файлов из писем IBM Notes. Происходит фильтрация нужных писем по двум критериям (From и DeliveredDate). Чтобы не забыть выложу тут) может еще кому-нибудь пригодиться

Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Domino;

namespace IBMnotes
{
    class Program
    {
        static void Main(string[] args)
        {
            GetAttachments(@"D:\temp\");
        }

         static void GetAttachments(String fileSavePath)
        {
            String NoteServer = "Адрес сервера";
            string NateMailFile = "расположение MailFile на сервере .nsf";

            NotesDateTime _datetime = null;

            NotesSession session = new NotesSession();
            session.Initialize("");

            //Get connection to database.
            Domino.NotesDatabase NotesDb = session.GetDatabase(NoteServer, NateMailFile, false);
            //NotesDb.Open();

            Console.WriteLine(NotesDb.Title);
            Console.WriteLine("");

            //поиск писем по 2 критериям (From и DeliveredDate)
            NotesDocumentCollection NotesDocuments = NotesDb.Search("@Contains(From;'MicroStrategy Distribution Services') & DeliveredDate=[22.08.2017]", _datetime, 0);
         

            //Console.WriteLine(NotesDocuments.Count);

            if (NotesDocuments.Count > 0)
            {
                NotesDocument document = NotesDocuments.GetFirstDocument();
                while (document != null)
                {
                    // Check if any attachments
                    if (document.HasEmbedded)
                    {
                        object[] items = (object[])document.Items;
                        foreach (NotesItem item in items)
                        {
                            if (item.Name.Equals("$FILE"))
                            {
                                object[] values = (object[])item.Values;
                                document.GetAttachment(values[0].ToString()).ExtractFile(fileSavePath + values[0].ToString());
                            }
                        }
                    }

                    //Console.WriteLine(document.GetItemValue("DeliveredDate")[0]);
                    //Console.WriteLine(document.GetItemValue("body")[0]);

                    document = NotesDocuments.GetNextDocument(document);
                }
            }
        }
    }

    
}
...
Рейтинг: 0 / 0
Сохранение вложенных файлов из писем IBM Notes на C#
    #39509444
Garrick
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
msleg, мне кажется как-то так Examples: EmbeddedObjects property (NotesRichTextItem - LotusScript) было бы правильнее.
Код: vbnet
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Dim doc As NotesDocument
Dim rtitem As Variant
'...set value of doc...
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
  Forall o In rtitem.EmbeddedObjects
    If ( o.Type = EMBED_ATTACHMENT ) Then
      Call o.ExtractFile( "c:\samples\" & o.Source )
      Call o.Remove
      Call doc.Save( False, True )
    End If
  End Forall
End If


Только
Код: vbnet
1.
2.
Call o.Remove
Call doc.Save( False, True )


уберите!
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / Сохранение вложенных файлов из писем IBM Notes на C#
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]