SetContentFromBytes(stream, "message/rfc822", ENC_BASE64) dropping MIME part

I am trying to create a MIME structure that contains both a text/html part with some text and also an attached message/rfc822. My code basically works, minus the little detail that the actual rfc822/message contents is dropped into a blackhole. When I change the MIME type to application/msword for example, it works correctly. I think this might be a bug.

I unloaded the router to look at the generated messages and when I look at the doc properties I see an empty MIME part:

Field Name: Body

Data Type: MIME Part

Data Length: 54 bytes

Seq Num: 1

Dup Item ID: 2

Field Flags: SIGN SEAL

"

–==IFJRGLKFGIR52052UHRUHIHD–

"

So I think there might be either a documentation error or a bug in the software. I really would like to get this working, if anyone has some insight, I’d appreciate it. Here is my code (blatantly copied from other forum posts) ( the part that composes the RFC822 message is not pasted here), but it’s straight RFC822.

Sub HTMLize

'Declare Variables

Dim s As New NotesSession

Dim db As NotesDatabase

Dim body As NotesMIMEEntity, bodyChild As NotesMimeEntity

Dim header As NotesMIMEHeader

Dim stream As NotesStream

Dim host As String

Dim message As NotesDocument



Set db = s.CurrentDatabase



s.ConvertMIME = False 

’ Do not convert MIME to rich text Set stream =

s.CreateStream



Set message = db.CreateDocument

message.Form = "memo"



Set body = message.CreateMIMEEntity



message.Subject = "Sample HTML email via MIME"



message.SendTo = "me"  



Set stream = s.CreateStream()

’ Open the HTML (Title doesn’t matter since it doesn’t appear anywhere)

Call stream.WriteText ("<html><head><title>Domino Spam submission</title>")





Call stream.WriteText ({</head>})

Call stream.WriteText  ({<body text="#666666" bgcolor="#FFFFFF"  leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">})

’ BEGIN: HTML body

Call Stream.WriteText ({Attached is an inline spam message<br>})

Call Stream.WriteText ({<p><br>})

Call stream.WriteText  ({</body></html>})

'Child mime entity which is going to contain the HTML which we put in the stream

Set bodyChild = body.CreateChildEntity()

Call bodyChild.SetContentFromText (stream, "text/html;charset=iso-8859-1", ENC_BASE64)  

Call stream.Close

Call stream.Truncate

'Committing the stream to the child mime entity - done

'A new child mime entity to hold a file attachment

Set bodyChild = body.CreateChildEntity()

Set header = bodyChild.createHeader("Content-Type")

Call header.setHeaderVal("multipart/mixed")



Set header = 	bodyChild.createHeader("Content-Disposition")

Call header.setHeaderValandParams( |attachment; filename="spam.eml"| ) 

Set header = bodyChild.createHeader("Content-ID")

Call header.setHeaderVal( |"spam.eml"| ) 	



Set stream = s.CreateStream()  

stream.Open( "c:\spam.eml") 

If stream.Bytes = 0 Then

	Print "File has no content"

End If

Call bodyChild.SetContentFromBytes(stream, "message/rfc822",  ENC_BASE64)

Stream.Close

'Send the email

Call message.Send (False)  



s.ConvertMIME = True ' Restore conversion		

End Sub

Subject: RE: SetContentFromBytes(stream, “message/rfc822”, ENC_BASE64) dropping MIME part

The message body and the attachment need to be siblings – the HTML content can’t be a parent.Example