Problem with creating MIME mail - notesMIMEEntity.Preamble property

After some complicated testing we found that there is a problem with using Preamble property in notesMIMEEntity object.

If you use the LS code like:

S.ConvertMIME = False

Set MIME_Parent = DOC.CreateMIMEEntity( “Body” )

Set MIME_Header = MIME_Parent.CreateHeader( “MIME-Version” )

Call MIME_Header.SetHeaderVal( “1.0” )

Set MIME_Header = MIME_Parent.CreateHeader( “Content-Type” )

Call MIME_Header.SetHeaderValAndParams( |multipart/alternative; boundary=“the_boundary_of_multipart_alternative_messages”| )

MIME_Parent.Preamble = “If you are reading this text, your mailer does not understand MIME multipart messages.”

Set MIME_Text = MIME_Parent.CreateChildEntity

Set Stream = S.CreateStream

Call Stream.WriteText( “Plain Text …” )

Call MIME_Text.SetContentFromText( Stream,“text/plain; charset=UTF-8”, ENC_NONE )

Call MIME_Text.EncodeContent( ENC_QUOTED_PRINTABLE )

Call Stream.Close

Set MIME_HTML = MIME_Parent.CreateChildEntity

Set Stream = S.CreateStream

Call Stream.WriteText( “

HTML text
” )

Call MIME_HTML.SetContentFromText( Stream,“text/html; charset=UTF-8”, ENC_NONE )

Call MIME_HTML.EncodeContent( ENC_QUOTED_PRINTABLE )

Call Stream.Close

Status = DOC.CloseMIMEEntities( True )

Status = DOC.Save( True, False )

S.ConvertMIME = True

then the result in Body MIME field is:

MIME-Version: 1.0

X-Notes-Item: TemplateMimeB; name=Form

Content-Type: multipart/alternative;

boundary=“the_boundary_of_multipart_alternative_messages

If you are reading this text, your mailer does not understand MIME multipart messages.

the_boundary_of_multipart_alternative_messages

Content-Transfer-Encoding: quoted-printable

Content-Type: text/plain; charset=UTF-8

Basic Text=

the_boundary_of_multipart_alternative_messages

Content-Transfer-Encoding: quoted-printable

Content-Type: text/html; charset=UTF-8

HTML text
=

the_boundary_of_multipart_alternative_messages

As you can see there is a line which should not be here - it is related to the item “Form” that is also in the Notes document:

X-Notes-Item: TemplateMimeB; name=Form

If you have more items in the document then the line is repeated for each one.

If you do not set MIME_Parent.Preamble property then the the result is OK:

Content-Type: multipart/alternative;

boundary=“the_boundary_of_multipart_alternative_messages

the_boundary_of_multipart_alternative_messages

Content-Transfer-Encoding: quoted-printable

Content-Type: text/plain; charset=UTF-8

Basic Text=

… and so on.

The big problem is that if you set MIME_Parent.Preamble property it is not possible to update the MIME content in the document at all (after saving the document and setting MIME_Parent entity again).

The method CloseMIMEEntities always returns error code 4000 then.

Milos Lapis

MLC