Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Object variable not set error in HTML email button

Posted on 2009-05-12
4
Medium Priority
?
446 Views
Last Modified: 2013-11-16
HTML memo button works on Notes 8 client and does not work for some Notes 7 clients with error message: "Object variable not set".  
What would cause this error ?
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:  |
	' <br> (break - new line)
	' <b> bold text </b>
	' <font size=4> text - make any size you like  </font>
	' url has to be enclosed in single quote:  <img src='http://www.google.com/images/pic00000.jpg'/>
	' another example:   <a href ='http://www.google.com/review.html'>Click here to get the white paper.</a>
	
	html = |    
<img src='http://www.google.com/images/pic00000.jpg'/>
 <br><font size=6><b>This is my first line for body text.
	</font></b><br><br>More body text
And more body text.	
	Here is example of font size:
	<br><br><font size=4><b>Font 4 text.</font></b>is a little larger.
	<br><br><font size=4><b><a href =''http://www.google.com/review.html''>Click here to get the white paper and more information.</a>
	<br><br><font size = 1>copyright
	<br><br><br>  |
	
	
	'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

Open in new window

0
Comment
Question by:KTTKTT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 24374833
IS it version specific  in 7 ?

Have you run it in debug mode ?

How about adding debug output to a log ?

   
I hope this helps !
0
 

Author Comment

by:KTTKTT
ID: 24375215
V7.2   My machine hangs when attempting to run debug, but it generally stalls at :
Set memo = ComposeMimeMemoEx(Body ,html )  

How do I debut output to a log?
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 24377224
I would check to make sure that the body and HTML exist .

also shouldn't it be

Set memo = ComposeMimeMemoEx(doc.Body ,html )  or doc.subject in the first param.


I hope this helps !
0
 

Accepted Solution

by:
KTTKTT earned 0 total points
ID: 25188406
I've had other programmers review code - they ran it w/out problems.  Still don't know why it works for version 8 Notes and not version 7.  Hoping everyone will upgrade soon. Closing request.  Thanks for your assistance.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question