Hi, everyone.
I’m working with MIME for the first time, trying to create HTML mail from Notes. I have an agent that will create an HTML e-mail and send it to a user; however, I want to be able to resend the e-mail to other users, including Notes users.
I’ve noticed that INetSendTo is causing me problems. When I send an e-mail to a Notes user, the SendTo field is populated. When I send an e-mail to an Internet user, the INetSendTo field appears to come into play.
It appears that once there is a SendTo field on my document, I can’t send out to an Internet user. Changing SendTo via LotusScript does not modify the field; rather, it modifies the INetSendTo field. What’s with this???
I have looked high and low for a tutorial on HTML mail in Notes, but have not found very much. Can anyone point me in the right direction?
See the code below. I want to be able to resend the document as many times as necessary to both Notes and Internet users. There has got to be an easier way to do this. Eventually, I want to mail to over 5,000 people that includes both Notes and Internet e-mail users.
Sub Initialize
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim fileNum%
Dim text$
Dim theHTML$
Dim strHTMLMessage As String
' Define a body object that represents the HTML/MIME content of a document
Dim body As NotesMIMEEntity
' Define a stream of binary or character data
Dim stream As NotesStream
Set db = session.CurrentDatabase
' Import the HTML File
Dim theHTMLfile As Variant
theHTMLfile = ws.OpenFileDialog( False , "Open HTML file" , "HTML files|*.htm*" , "C:\" , "" )
If Isempty(theHTMLfile) Then
Messagebox " HTML file input cancelled per user request. ", 0, " Operation cancelled "
Exit Sub
End If
%REM
’ Here’s one way of reading the HTML file
’ See below for another way
fileNum% = Freefile()
Open theHTMLfile(0) For Input As fileNum%
Do While Not Eof(fileNum%)
' Read each individual line of the file.
Line Input #fileNum%, text$
theHTML$ = theHTML$ + text$
Loop
strHTMLMessage = theHTML$
%ENDREM
' Create the new HTML mail document
Dim mailDoc As New NotesDocument( db )
' Set form name as Memo
mailDoc.form = "Memo"
' Create the MIME entity
Set body = mailDoc.CreateMIMEEntity
' Set the mail subject
Dim theSubject$
Do Until theSubject$ <> ""
theSubject$ = Inputbox$("Enter a subject for this document. ", " Create Subject")
Loop
Set header = body.CreateHeader( "Subject" )
Call header.SetHeaderVal( theSubject$ )
' Update mail body with HTML text from external file
Set stream = session.CreateStream
' Alternate way to read the HTML file
If Not stream.Open(theHTMLfile(0), "ASCII") Then
Messagebox " Error Opening File", 0, " The specified file could not be opened for reading. "
Exit Sub
Else
strHTMLMessage = stream.ReadText()
Call stream.Close
End If
' End of alternate way to read the HTML file
' Sets the content of a MIME entity from text. Content-Transfer-Encoding is "8-bit"
Call stream.WriteText( strHTMLMessage )
Call body.SetContentFromText ( stream, "text/html; charset=UTF-8", ENC_IDENTITY_8BIT )
Dim recipient$
Do Until recipient$ <> ""
recipient$ = Inputbox$("Enter a Notes or Internet e-mail address. ", " Specify Recipient")
Loop
maildoc.SendTo = recipient$
maildoc.Subject = theSubject$
Call maildoc.Save( True, False )
Call maildoc.Send( False )
' Call ws.EditDocument( False, mailDoc, False )
End Sub