Solved

Type Mistmatch....again

Posted on 2009-05-18
6
166 Views
Last Modified: 2013-12-18
Working on some code to send a tracer after doing some basci evaluations. I have used this in other areas but I get an instant type mismatch error, can't even get to see anything in debugger. I have Option Declare set. What do I have wrong in this case.
Sub Click(Source As Button)
	Dim ws As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim email As New NotesDatabase("", "")
	Dim doc As NotesDocument, memo As NotesDocument
	Dim body As NotesRichTextItem
	Set uidoc = ws.CurrentDocument
	If (uidoc.EditMode) Then Call uidoc.Save
	Set doc = uidoc.Document
	uidoc.EditMode = True
	If doc.am_init_approved(0) = "y" And doc.am_init_flag(0) <> "done" Then 
		Set memo = email.CreateDocument
		memo.Form = "Memo"
		memo.Subject = "Congratulations! You are now a " & doc.GetItemValue("title_vis")(0) & "."
		memo.Remark = "I am pleased to announce you have now been approved as a " & doc.GetItemValue("title_vis")(0) 
		memo.SendTo = "Field Technology"
		memo.CopyTo = "Field Technology"
	        ' add a body and a doc link
		Set body = memo.CreateRichTextItem("Body")
		Call body.AppendDocLink(doc, "", "")
		Call uidoc.FieldSetText("am_init_flag", "done")
		Call uidoc.Save
	       ' send the memo and close the form
		Call memo.Send(False)
		Call uidoc.Close(True)
	End If
End Sub

Open in new window

0
Comment
Question by:jforget1
[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
  • 3
  • 3
6 Comments
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24414420
Not sure why you're getting a type mismatch.  I don't see any type errors here.

The only thing I notice is that you don't open the email database before calling CreateDocument.

Try adding this line before line #12:

    Call email.OpenMail

0
 

Author Comment

by:jforget1
ID: 24414480
I actually took that out, I thought it might have been causing the issue. I will put it back in to see if maybe I fixed it somewhere else.
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24414546
Maybe the error is caused by the uidoc.Save?  Is there any code in that form's QuerySave or PostSave events?
0
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!

 

Author Comment

by:jforget1
ID: 24414596
Well adding that back in now has it working. One final issue is the body of the memo is not carrying over, only the doclink. Have not used the memo type that often, how do I get the body of the message to carry to the email? I tried moving it down after the body has been set. No luck.
If doc.am_init_approved(0) = "y" And doc.am_init_flag(0) <> "done" Then 
		Call email.OpenMail		
		Set memo = email.CreateDocument
		memo.Form = "Memo"
		memo.Subject = "Congratulations! You are now a " & doc.GetItemValue("title_vis")(0) & "."
		memo.SendTo = "Field Technology"
		memo.CopyTo = "Field Technology"
	        ' add a body and a doc link
		Set body = memo.CreateRichTextItem("Body")
		Call body.AppendDocLink(doc, "", "")
		memo.body = "I am pleased to announce you have now been approved as a " & doc.GetItemValue("title_vis")(0)
		Call uidoc.FieldSetText("am_init_flag", "done")
		Call uidoc.Save
	       ' send the memo and close the form
		Call memo.Send(False)
		Call uidoc.Close(True)
	End If

Open in new window

0
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 500 total points
ID: 24414807
There are three ways to set the body of an email: Plain Text, RichText, and MIME.  These three types are independent, and cannot be mixed.  You have mixed plain text and RichText in the same script.

Line 9 creates a new RichText item in the memo.  This allows you to add doc-links and formatted text.

But, by setting memo.body to a string in line 11, you are forcing the body to be plain text.  The RichText operations that precede this line are over-written with the contents of the string.

The bottom line here is to continue using the RichText methods to add text to your RichText item.  In this case, simply replace line 11 with this:

    Call body.AppendText("I am pleased to announce you have now been approved as a " & doc.GetItemValue("title_vis")(0))
0
 

Author Closing Comment

by:jforget1
ID: 31582684
As always you are the master on these, that adjustment worked like a charm, thanks for the help.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I delete a user in IBM Lotus Notes 2 214
Domino Application - View Refresh on Subform 15 101
ESXCLI upgrade command 1 162
Lotus Notes db size issue 5 8
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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