To send HTML mails in R6, you have to use the setContentFromText method in the NotesMIMEEntity class. To add inline images, use the setContentFromBytes method in the same class, like this:
Dim session as New NotesSession()
session.convertMIME = False ' Do not convert to rich text
Dim currentDb As NotesDatabase
Set currentDb = session.currentDatabase
Dim path As String
path = "c:temptest.html"
Dim message As NotesDocument
Set message = currentDb.createDocument()
Call message.replaceItemValue("Form", "memo")
Call message.replaceItemValue("From", "[email protected]")
Call message.replaceItemValue("Subject", _
"HTML email via MIME")
Call message.replaceItemValue("SendTo", "[email protected]")
Dim body As NotesMIMEEntity
Set body = message.CreateMIMEEntity
Dim mh As NotesMimeHeader
Set mh = body.CreateHeader({MIME-Version})
Call mh.SetHeaderVal("1.0")
Set mh = body.CreateHeader("Content-Type")
Call mh.SetHeaderValAndParams( _
{multipart/related;boundary="=NextPart_="})
Dim mc As NotesMIMEEntity
Set mc = body.createChildEntity()
Dim stream As NotesStream
Set stream = session.createStream()
If Not stream.open(path, "ISO-8859-1") Then
Error 2000, "Could not open file"
End If
Call mc.setContentFromText(stream, _
{text/html;charset="iso-8859-1"}, ENC_NONE)
Call stream.close()
Call addImage(body, "C:tempimage1.gif")
Call addImage(body, "C:tempimage2.gif")
Call message.send(False)
The addImage method looks like this:
Public Sub addImage(body As NotesMimeEntity, _
imagePath As String)
Dim id As String
Dim stream As NotesStream
Dim mh As NotesMimeHeader
Dim mc As NotesMIMEEntity
id = Strrightback(imagePath, "")
Set stream = session.createStream()
Set mc = body.createChildEntity()
Set mh = mc.createHeader({Content-ID})
Call mh.setHeaderVal(id)
Call stream.open(imagePath)
Call mc.setContentFromBytes(stream, _
"image/gif;name=""" + id + """", ENC_IDENTITY_BINARY)
Call stream.close
End Sub
The HTML code must refer to the images via URL:s containing cid and the ”path” to the image, like this:
<img src="cid:imagename.gif" />
Found this great tip via LDD, posted by Raymond Neeves.
Very cool. I Did something similar in sending a Notes e-mail from an XML call.
http://www.crossedconnections.org/w/?p=45
Nice!
Dear Sir, I can’t use your scripts since there are some errors below, and I’m unable to find any information from Notes help, my version is R5.0.13 could you give me some help? Thanks.
Dim mh As NotesMimeHeader
Set mh = body.CreateHeader({MIME-Version})
Call mh.SetHeaderVal(”1.0”)
Set mh = body.CreateHeader(”Content-Type”)
Call mh.SetHeaderValAndParams( _
{multipart/related;boundary=”=NextPart_=”})
Jason, it only works in R6 and above.
After some tests with Gmail account and Thunderbird mail client, I had to update AddImage() sub because the value for ”Content-ID” header must be enclosed with chars.
Call mh.setHeaderVal(””)
Bye
CD
previous post was bad-translated!
”less than” symbol & id & ”greater then” symbol
Call mh.setHeaderVal(”<” & id & ”>”)
Hi,
I am a MCA graduate and came accross Lotus Notes as part of my academic project at M/s. Tata Steel,India. I found it quite interesting and want to specialize in this field.
But I cant find any helpful books on Lotus Script that will help me built my foundation on the topic.
I would be very grateful if you please let me know any ebooks or related sites that helps the beginers.
In internet lots of help is available but they are either above my level or in chunks of examples. I need to build a foundation now.
Looking forward to your response.
My mail id’s is
[email protected]
[email protected]
Thanking you.
Hardeep Singh
India
Try searching on Amazon.com with the keyword LotusScript. There are several books that may be of interest!
how can i use STRRightBack method in lotusscript. I dont know the proper syntax. can anybody send me a small working example
It finds the ”right-most” part of a string starting from the ”right-most” second argument, so StrRightBack(”Johan Is Back”, ” ”) gives you ”Back”.
Look at:
https://qp.research.ibm.com/help/help7_designer.nsf/f4b82fbb75e942a6852566ac0037f284/e1f903a7f19c9d5e8525704a00405c7b?OpenDocument
Mr. Johan, I’ve tried to use this tip, but the format information the HTML content I’d like to send is not respected (font size, for example!). What can I do to fix this? Thx!
What is the problem and how do the HTML look like?
Mr Johan, I am trying to send an email using Lotusscript. This script reads values from two rich text fields, composes an email and appends the rich text field values in mail body. The problem is that the mail always goes as Text and any colored text from rich text field is not coming in same format in mail body. Can you suggest some thing?
I’m trying to use StrRightBack to display the contents of a string appearing next to a ”-”. The code I’m using is:
Call doc.ReplaceItemValue( ”FeaturedBlog_Title”, Strrightback(blogDoc.Categories, ”-”))
I don’t get an error when I save the document, but I get a type mismatch in the client. Categories is a text field. Can you help?
Thanks,
Steve
You must do something like:
Call doc.ReplaceItemValue( “FeaturedBlog_Titleâ€, Strrightback(blogDoc.Categories(0), “-â€))
very nice script