Progmatic image to display in body field

Hi to all,

I’ve been trying to find a progmatic way to insert an image/disclaimer into the body field when sending or replying. GetProfileField from a profile doc is not satisfactory due to the users having to manually setup their own (and also will not always show up accurately when replying with history). I’ve also tried accomplishing this with appendrtitem, copyrtitem, etc. within the coreEmailClasses, but this requires a save and reopen the document. Has anyone been able to accomplish this by other means? possible by inserting a MIMEentity?

Previous post is found:

http://www-10.lotus.com/ldd/46dom.nsf/DateAllThreadedweb/ae3386325f71197385256fb7005691e0?OpenDocument

TIA

Geoff-

Subject: Progmatic image to display in body field…

Here is a portion of a script I use to create a memo, backend, and have a linked image embedded in the body. Maybe it will help you a little.

-Jeremy

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim docMail As NotesDocument

Dim docNow As NotesDocument

Dim recordDoc As NotesDocument

Dim sendRecordDoc As NotesDocument

Dim mimeRoot As NotesMimeEntity, mime As NotesMimeEntity

Dim header As NotesMimeHeader

Dim stream As NotesStream

Dim uidoc As NotesUIDocument

Dim imagename As String

Dim view As NotesView

Dim sendRecordView As NotesView

Dim sendhistory As NotesItem

Dim boxType As Long

Dim post$



Set db = session.CurrentDatabase

Set uidoc = workspace.CurrentDocument

Set docMail = db.CreateDocument

Set docNow = uidoc.Document



	

'Compose and send message

	session.ConvertMIME = False ' Do not convert MIME to rich text	

	docMail.Form = "Memo"

	docMail.Subject = docNow.Subject(0)

	docMail.Principal = docNow.SendFrom(0)

	imagename = docNow.ImageName(0)

'Create main MIME message 

	Set stream = session.CreateStream 

	Set MIMERoot = docMail.CreateMIMEEntity ' message root

'Create child entities 

	Set mime = MIMERoot.CreateChildEntity

	Set header = MIMERoot.getNthHeader("Content-Type")

	Call header.SetHeaderVal("multipart/related") 

'Create Message text 

	Call stream.WriteText(docNow.MessageText(0) & |<style>TD {font-family:arial;font-size:9pt;}</style><table width="100%" border="0" cellspacing="0">| &_

	|<tr><td><a href="http://www.myserver.com/applications/mmail.nsf/pdfPage| & docNow.ItemNumber(0) & |?openpage"><img src="http://www.myserver.com/applications/mmail.nsf/| & imagename & |?OpenImageResource"></a>| &_ 

	|</td></tr><tr>&nbsp</tr></table>|)

	Call stream.WriteText(|<table width="100%" border="0" cellspacing="0"><tr>&nbsp</tr></table>|)

	Call mime.SetContentFromText(stream,"text/html",ENC_NONE)

	Call stream.Close

	

'Create inline image reference 

	Set mime = MIMERoot.CreateChildEntity 

	Call stream.Open("http://www.myserver.com/applications/mmail.nsf/" & imagename & "?OpenImageResource")

	Call mime.SetContentFromBytes(stream, "image/jpeg",ENC_NONE)

	Call stream.Close

	Call mime.EncodeContent(ENC_BASE64)

	Set header = mime.CreateHeader("Content-ID")

	Call header.SetHeaderVal("<image.jpg>")

	Call docMail.Send(False, docNow.SendTo(0))

	session.ConvertMIME = True ' Restore conversion

End Sub