HTML Email Memo button "Object Variable not set"

HTML memo button works on Notes 8 client and does not work for some Notes 7.2 clients with error message: “Object variable not set”. What would cause this error ?

The error seems to occur on this line:

Set memo = ComposeMimeMemoEx(Body ,html )

Email button code:

Sub Click(Source As Button)

'1st email note serves as confirmation, rsvp

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set doc = New NotesDocument( db )

doc.Form = “Memo”

doc.SendTo = “xyx.xxx.com” 'CHANGE SEND TO HERE

doc.Subject = “This is my subject line” 'CHANGE SUBJECT LINE HERE

doc.body = "Notification - I clicked this button and will attend’ " 'CHANGE BODY TEXT HERE

Call doc.Send( False )

'End of 1st email noe

'2nd Email note - Allow user to Compose HTML Memo

Dim memo As NotesuiDocument

Dim html As Variant

’ Add the Email Body Text between the beginning and Ending Vertical Bar: |


(break - new line)

bold text

’ text - make any size you like

’ url has to be enclosed in single quote:

’ another example: Click here to get the white paper.

html = |


This is my first line for body text.



More body text

And more body text.

Here is example of font size:



Font 4 text.is a little larger.



<a href =‘‘http://www.google.com/review.html’’>Click here to get the white paper and more information.



copyright




|

'ADD THE SUBJECT HERE:

Set memo = ComposeMimeMemoEx(Body ,html )

Call memo.FieldSetText(“Subject”, “xyz white paper: and more information” ) ’ Add Subject text in quotes

’ Call memo.FieldSetText(“EnterSendTo”, “”) 'If needed, add intranet id BETWEEN quotes for the SendTo field and remove the ’ Comment single quote

End Sub

Function ComposeMimeMemoEx(Byval subject As String, Byval html As String) As NotesUIDocument

Dim ws As New NotesUIWorkspace

Dim sess As New NotesSession

Dim db As New NotesDatabase(“”, “”)

Dim uiTemp As NotesUIDocument, memo As NotesUiDocument

Dim docTemp As NotesDocument

Dim body As NotesMimeEntity

Dim stream As NotesStream

On Error Goto CATCH

’ create MIME using a temp document

Call db.OpenMail

sess.ConvertMime = False

Set docTemp = db.CreateDocument

Set body = docTemp.CreateMIMEEntity(“Body”)

Set stream = sess.CreateStream

Call stream.WriteText(html)

Call body.SetContentFromText(stream, {text/html; charset=“iso-8859-1”}, ENC_QUOTED_PRINTABLE)

Call docTemp.CloseMIMEEntities(True, “Body”)

sess.ConvertMime = True

Call docTemp.Save(True, False)

’ copy generated HTML to the clipboard

Set uiTemp = ws.EditDocument(True, docTemp)

Call uiTemp.GotoField(“Body”)

Call uiTemp.SelectAll

Call uiTemp.Copy

uiTemp.Document.SaveOptions = “0”

uiTemp.Document.MailOptions = “0”

Call uiTemp.Close

Call docTemp.Remove(True)

Set docTemp = Nothing

’ compose the new memo

Set memo = ws.ComposeDocument(db.Server, db.Filepath, “Memo”)

Call memo.FieldSetText(“Subject”, subject)

Call memo.GotoField(“Body”)

Call memo.Paste

Set ComposeMimeMemoEx = memo

Exit Function

CATCH:

If (Not docTemp Is Nothing) Then If (Not docTemp.IsNewNote) Then Call docTemp.Remove(True)

Exit Function

End Function

Subject: HTML Email Memo button “Object Variable not set”

Kimberly ,

Can you put error handler in your code and tell us the line number where “Object variable not set” error is coming? I don’t see any in your “ComposeMimeMemoEx” function. It’s bad practice.

Rishi

Subject: RE: HTML Email Memo button “Object Variable not set”

Debug tells me the error occurs on this line: Set memo = ComposeMimeMemoEx(Body ,html )

Subject: RE: HTML Email Memo button “Object Variable not set”

It’s telling at that line because “ComposeMimeMemoEx” function doesn’t have error handler. So if any error throw in “ComposeMimeMemoEx” function it will give the line number which you have mentioned.

Rishi