I’m getting a type mismatch error on this script which we want ot use in an action button from user’s inbox, to forward poss psam email onto to a company we are using to filter out spam email.
The script works just fine in 5.11. Just tried it out on 6.0 and got the type mismatch error.
This is the srcipt
Dim s As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim uidoc As NotesUIDocument
Dim ws As New notesuiworkspace
Dim object As notesembeddedobject
Dim item As NotesItem
Set uidoc = ws.currentdocument
Set doc = uidoc.Document
Set db = s.CurrentDatabase
'open file for output
f=Freefile()
outputfile="c:\tempfile.txt"
Open outputfile For Output As f
Forall i In doc.Items
If i.name <> "Body" Then
Set item = doc.GetFirstItem(i.name)
Print #f,i.name &":"
Forall v In item.Values
Print #f,v
End Forall
End If
End Forall
Close f
'email file
Dim newdoc As NotesDocument
Set newdoc = New NotesDocument(db)
newdoc.Form="Memo"
newdoc.subject = "Possible spam"
Dim rtitem As notesrichtextitem
Set rtitem = New notesrichtextitem(newdoc,"Body")
Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "",outputfile)
Call newdoc.Send(False,"Sue Gardner")
Kill outputfile
Messagebox "This email has been forwarded on to FrontBridge"
Call uidoc.close()
Subject: REF: Script in Action button - Type MisMatch
This has nothing to do with the version of Notes it runs in, it’s more prosaic than that.
You should always run stuff like this through the debugger, and you will have your answer. The code looks OK on cursory glance (although there are lots of hard-coded values in there, tsk!), but if you dig deeper, I think you will find that your Type Mismatch occurs when you process certain fields that may or may not exist in specific Memo documents.
For example, this line produces that error on any mail that contains a $Links item ($Links contains special data type values, so NotesItem.Values has a hard time with it):
Subject: RE: REF: Script in Action button - Type MisMatch
Hi Ben
Yes I did run debugger and got the error
at same place. have got round it by adding the line On Error Resume Next. It seems to work now, is this acceptable ? Or should I have added something else ?
orall i In doc.Items
If i.name <> "Body" Then
Set item = doc.GetFirstItem(i.name)
On Error Resume Next
Print #f,i.name &":"
Forall v In item.Values
Print #f,v