Creating a multipart MIME message from a string

I’m trying to create a multipart MIME message out of a MIME HTML string. The string is dynamically generated based on the content that the user wants to mail. A sample string looks like this:

==============

Content-Type: multipart/related; boundary=“=related 005E56BC8525759F=”

This is a multipart message in MIME format.

–=related 005E56BC8525759F=

Content-Type: text/html; charset=“US-ASCII”



Rich Text Test Alternate Form



Title:        test

042109




Rich Text:


123



         

           My Company LLP


                   

Maynard Krebs |

Americas IT - United States |

 Customer Application Services

         

           123 Anywhere St, Hollywood CA 90210

                   

Phone: +1-123-456-7890 |

Fax: +1-123-456-7890


                   

For technology help, please visit Global

Self Help |

Thank you for considering the environmental impact of printing emails.



–=related 005E56BC8525759F=

Content-Type: image/gif

Content-ID: <_1_08F5E3DC08F5E188005E56BC8525759F>

Content-Transfer-Encoding: base64

R0lGODlh+QBEAMQAAP///8zMzP/dAX9/f/Pz89jY2Ojo6MPDw6Ghod3d3fb29rKysuXl5YiIiP/o

Ve7u7v/xmJCQkP//zKqqqpmZmbu7u9TU1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAA

AAAALAAAAAD5AEQAAAX/ICCOZGmeaKqubOu+cCzPdG3feK7vfO//wKBwSCwaT4GkcslsOp/QqHRK

rVqv2Kx2y8UevyqJYEwum8/oNNkBAbvfcCJETa+f2ZK4fs+vSRx2gWpsfYWGhyhzgotjeIiPkH1/

jIIQeZGYmW6KlIOWmqChRICdd5+iqKk8YqVlhKqwsTakpY6yt7gurJ2vub6/J5yCtsDFxZPDl8bL

JQEEIgapwp7KzNYjAdEAzgAEBSIEz4+0aMTX59ja3AQB0N8ABdracNOubej4zerP7O4iBe+yieAG

YJ4Qco1O5VuYbiC/dgXfARy4rxtEA+/C7diVkKFHfQ4t+oMXsGK/ghAn/8KTN4OUuY8wBW57OFKl

zHUXU0o0CZGAwRJ/esEc2nCmyIj/SoY8aUDnP57QnBZ8Vo2o1W1QkZKkuDRn0qddo36FJ+6qWaxh

tdrM2nRsvLRtt56dy9UoU4lK7XqV+1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HY9xU1pAi+KFaKY5j1oiWBdDYigk9L1Oqg9

AEsLqACW5sck7+XJesSzX59Ghy1rROYQQ3uS8oS3vyih6Ulti9fZSOAyJ1Xggw0QYAmAxwDSNaA0

CohXAywGOscNqohNisD/XKgOfCggTrfSmBB5iMUbMACAa0tAFlvAACMf5al5wFASio4ApPel8Sdr

HIK3WrXFNMbxCy4C4x336IsQAAA7

–=related 005E56BC8525759F=–

===============

I understand how to create child entities in the NotesMIMEEntity class and insert content for single part MIME data, using setContentFromText and setContentFromBytes. But is there a method that can handle true MIME HTML and create the appropriate entities out of it automatically? I really want to avoid having to parse this string for ContextType values, break it up at its boundaries into multiple strings, and create the child entites and feed them manually. There has to be a solution that’s not nearly as messy, right?

I searched the forums for an answer to this, but couldn’t find one, so if you could point me to an answer or give me an answer, that would be much appreciated. Thanks.