Help pls! Server panics when converting mime to richttext in a background agent. here is the code. Server crashes during the doc.save.
Elseif rtItem.Type = MIME_PART Then
Call subCreateTextFromMime ( doc , "rtfConvertedMime")
End If
Sub subCreateTextFromMime ( doc As NotesDocument, strFieldName As String )
Dim s As New NotesSession
Dim item As notesitem
Dim rtItem As NotesRichTextItem
Dim mime As NotesMimeEntity
Dim child As NotesMIMEEntity
Dim newitem As NotesItem
Dim stream As NotesStream
If Not doc Is Nothing Then
If Not doc.HasItem ( strfieldName ) Then
Set newitem = New NotesItem ( doc, strFieldName ,"")
Else
Set newitem = New NotesItem ( doc, strFieldName ,"")
Call doc.save(True, True)
End If
s.convertMime = False
Set item = doc.getfirstitem("Body")
If item.Type = MIME_PART Then
Set mime = item.GetMIMEEntity
If Not(mime Is Nothing) Then
Set stream = s.CreateStream
Call mime.GetContentAsText (stream)
stream.Position = 0
newItem.AppendToTextList stream.ReadText
stream.Truncate
Set child = mime.GetFirstChildEntity
While Not child Is Nothing
Set stream = s.CreateStream
Call child.GetContentAsText (stream)
Stream.Position = 0
newItem.AppendToTextList stream.ReadText
stream.Truncate
Set child = child.GetNextEntity (SEARCH_BREADTH)
Wend
End If
End If
Call doc.save(True, True)
End If
End Sub
thnx
thomas