Combining a MIME Entity with a Mail Memo's Body Field

I’m trying to put some HTML into every outgoing email my client sends (formatted text and a URL reference to an image on the corporate server).

Thanks to Rod Whitely, I’ve figured out to get HTML in an outbound email using CreateMIMEEntity. But the code I use to do this tries to create a brand new Body field, which of course results in an error (Item body already exists) when it runs since there’s already a Body field on the Memo.

How do I concatenate the new MIME Entity with my existing Body field?

Here’s my sample code, in the QuerySave event of my memo:

Sub Querysend(Source As Notesuidocument, Continue As Variant)

Dim doc As NotesDocument

Set doc = Source.Document



htmltext$ = {My Company<br>

123 My St.

My Town, MyState 12345

Phone: 123-456-7890 Fax: 123-456-7891

Email: me@my_company.com

<img

src=“http://www.my_company.com/database.nsf/mylogo.jpg?openImageResource”

alt=“My Logo” border=“0”>}

 Dim session As New NotesSession

 

 Dim html As NotesStream

 Set html = session.CreateStream

 html.WriteText htmltext$

 

 Dim mime As NotesMIMEEntity

 Set mime = doc.CreateMIMEEntity("Body")

 mime.SetContentFromText html, "text/html", ENC_NONE

End Sub

I tried replacing it with this, in which I try to create different rich text and MIME entities and concanetate them, but it doesn’t work:

Sub Querysend(Source As Notesuidocument, Continue As Variant)

Dim doc As NotesDocument

Set doc = Source.Document



htmltext$ = {My Company<br>

123 My St.

My Town, MyState 12345

Phone: 123-456-7890 Fax: 123-456-7891

Email: me@my_company.com

<img

src=“http://www.my_company.com/database.nsf/mylogo.jpg?openImageResource”

alt=“My Logo” border=“0”>}

Dim rtitem1 As Variant

Dim rtitem2 As Variant



Dim session As New NotesSession



Dim html As NotesStream

Set html = session.CreateStream

html.WriteText htmltext$



Dim mime As NotesMIMEEntity

Set mime = doc.CreateMIMEEntity("Body2")

mime.SetContentFromText html, "text/html", ENC_NONE



Set rtitem1 = doc.GetFirstItem( "Body" )	

Set rtitem2 = doc.ReplaceItemValue("Body", rtitem1 & Body2 ) 

End Sub

Thanks very much in advance.

Subject: Combining a MIME Entity with a Mail Memo’s Body Field

Hello,I know your post is old and hope you still are present on this forum…

I have exactly the same problem and I don’t know how to combine an existing document to send out. I have the error message Item body already exists

Have you solved your problem ?

Thank you very much

Subject: Any reason for not using Actions, Tools, Preferences, Mail, Signature and specifying an HTML file?

Subject: Combining a MIME Entity with a Mail Memo’s Body Field

Just a wild guess:

Instead of creating a Body field, why not use the existing Body field? (that is what you describe)

So instead of using CreateMIMEEntity, look at the method GetMIMEEntity in the designer help.