Тема: Выгрузка Lotus документа в XML и сохранение вложения в переменную.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim strm As NotesStream
Dim inStream As NotesStream
'Dim atStream As NotesStream
Set inStream=session.Createstream() ' сохряненный файл на винте
Set strm = session.CreateStream() ' XML-ка
'Set atStream = session.CreateStream()
'Dim Base64File As New Xsd_base64binary
Dim conv As XSD_DATATYPE_CONVERTER
Set conv = New XSD_DATATYPE_CONVERTER
Dim doc As NotesDocument
Dim col As Notesdocumentcollection
Dim i As Integer
i = 0
Set db = session.CurrentDatabase
Dim View As NotesView
Set View=db.GetView("Inbox")
Set doc = View.GetFirstDocument
session.ConvertMIME = False
While Not((doc Is Nothing) Or Isnull(doc))
nam = {C:\text\} & i & {.xml}
Call strm.Open(nam)
Call strm.Truncate
Dim xml As String
Dim total As String
xml = {<?xml version='1.0' encoding='WINDOWS-1251'?>}+ Chr(13)
xml = xml + {<ApplicationFile xmlns:xsi="http://_.w3.org/2001/XMLSchema-instance">}+ Chr(13)
xml = xml + {<ApplicationsList>} + Chr(13)
xml = xml + {<zagolovok>} + doc.getItemValue("ЗАГОЛОВОК")(0) + {</zagolovok>} + Chr(13)
xml = xml + {<soderjanie>} + doc.getItemValue("СОДЕРЖАНИЕ_")(0) + {</soderjanie>} + Chr(13)
xml = xml + {<adresat>} + doc.getItemValue("АДРЕСАТ")(0) + {</adresat>} + Chr(13)
Dim rtitem As NotesRichTextItem
Set rtitem = doc.GetFirstItem("ПРИЛОЖЕНИЯ_")
Forall obj In rtitem.EmbeddedObjects
If ( obj.Type = EMBED_ATTACHMENT ) Then
Call obj.ExtractFile( "c:\text\" & obj.Source )
oname$ = obj.Name
Call obj.Remove
Call inStream.Open("c:\text\" & oname$, "binary") ' в поток inStream файл
' Call Base64File.Setvaluefromnotesstream(inStream) ' в Base64File загнали поток inStream
' Set atStream = Base64File.Getvalueasnotesstream() ' в atStream загнали Base64File, который в басе64
' atStream.Position=0
' xxx = atStream.ReadText() ' получили краказяблы ((((
yyyy= conv.notesStreamToBase64(inStream) ' УРА! ЭТА ХРЕФНЬ РАБОТАЕТ!
End If
End Forall
'xml = xml + {<prilojenie>} + plainText$ + {</prilojenie>} + Chr(13)
xml = xml + {</ApplicationsList>}
' xml = xml + {</ApplicationFile>}
Call strm.WriteText(xml)
Call strm.Close
Set doc=View.GetNextDocument(doc)
i = i + 1
Wend
session.ConvertMIME = True
End Sub