Changing MIME text drops some attachments

Hi

I’ve seen several posts in this area, but not describing my scenario exactly.

I have a simple document with a single Body field which uses MIME.

The Body field contains some text and a couple of attachments.

I have a piece of code that does a replace on a piece of text within the Body field and then re-writes it using SetContentFromText. This works fine, however 99% of the time its drops one or more of the attachments from the document…

I’m starting to think its a bug, but has anyone come across this one ?

Thanks…

Alan.

Sample Code as follows:


Sub Click(Source As Button)

Dim s As New NotesSession

Dim db As NotesDatabase

Dim col As NotesDocumentCollection

Dim doc As NotesDocument

Dim mime As NotesMimeEntity

Dim child As NotesMimeEntity

Dim stream As NotesStream

Dim orig_Body As Variant

Dim new_Body As Variant

s.ConvertMIME = False

Set db = s.CurrentDatabase

Set stream = s.CreateStream

Set col = db.UnprocessedDocuments

Set doc = col.GetFirstDocument

Set mime = doc.GetMIMEEntity

Set child = mime.GetFirstChildEntity

While Not(child Is Nothing)

encodingType = Cstr(child.encoding)

Select Case encodingType

Case “1727”

encodingType =ENC_BASE64

Case “1731”

encodingType =ENC_EXTENSION

Case “1728”

encodingType =ENC_IDENTITY_7BIT

Case “1729”

   	encodingType =ENC_EXTENSION

Case “1731”

encodingType =ENC_IDENTITY_8BIT

Case “1730”

encodingType =ENC_IDENTITY_BINARY

Case “1725”

encodingType =ENC_NONE

Case “1726”

encodingType =ENC_QUOTED_PRINTABLE			

End Select

If child.ContentSubType = “html” Then

orig_Body = child.ContentAsText

		

If Instr(1,orig_Body,"blah") > 0 Then

 new_Body = Replace(orig_Body,"blah","BLAH",1)			  

End If			

'####### Do text replacement here…

Call stream.WriteText(new_Body)

'##### Re-write the mime content using the origional encoding type

Call child.SetContentFromText(stream, "text/html; charset=US-ASCII", encodingType)

Call stream.Close

Call stream.Truncate

End If

Set child = child.GetNextSibling

Wend

'##### Close the Mime entity and save the doc

Call doc.CloseMIMEEntities(True, “Body”)

Call doc.Save(True,False)

s.ConvertMIME = True

End Sub

Subject: Fwd’d to development

Core/SB

Subject: Will do, will post the outcome, thanks Keith

Subject: SOLUTION

Had forgot to post this. At the end of the day this problem did not occur in 8.5.1 designed client, so the soltuion was to upgrade to 8.5.1 eclipse.

Alan