Possible Code Regression Found... Any thoughts for workarounds?

I have a call in to Lotus and they can not only reproduce the problem but think it’s a code regression after upgrading to 7.03…

I have an agent that acts Before New Mail Arrives (with code as old as the hills) that detaches a file from a message that arrives.

That’s it, nothing exciting.

This is the error in my log:

12/10/2007 07:08:14 AM Begin MIME to CD Conversion (Process: Router (00000B6C:00000012), Database: d:\Lotus\Domino\Data\DIR\dB.nsf, Note: 80000001)

12/10/2007 07:08:14 AM MIME to CD error (Process: Router (00000B6C:00000012), Database: d:\Lotus\Domino\Data\DIR\dB.nsf, Note: 80000001): Invalid or nonexistent document

12/10/2007 07:08:14 AM End MIME to CD Conversion (Process: Router (00000B6C:00000012), Database: d:\Lotus\Domino\Data\DIR\dB.nsf, Note: 80000001)

Here’s my response from IBM so far:

Its failing at the line:

    If ( rtitem.Type = RICHTEXT ) Then   

After thinking about the issue. I’m not sure a work around is possible, code wise, because at this point in time the message is in MIME not richtext. I even put in a session.ConvertMime = True at the beginning of the code and session.ConvertMime = False at the end or before any exit sub and this does not seem to be converting the MIME. In the interim I would suggest either rolling back or altering the agent to get a handle on the new doc in the mail box and then perform the action. I tested the code as an agent selection while the document was open and it worked fine.

Here’s my code:

On Error Goto errtrap

Dim session As New NotesSession 

Dim note As NotesDocument

Dim dbug As NotesLog

Dim db As NotesDatabase	

Dim agent As NotesAgent

Dim n As String

Dim it As NotesItem	



Set session = New NotesSession

Set sourcedb = session.CurrentDatabase

Set agent = session.CurrentAgent

n = agent.Name

REM Log steps in our processing for debug purposes

Set dbug = New NotesLog("Agent Log")

dbug.LogActions = True

dbug.OpenAgentLog

dbug.LogAction("begin")



Set db = session.CurrentDatabase

REM Make sure we have the note set correctly

If db Is Nothing Then dbug.LogAction("db is not set") Else dbug.LogAction("db is set")

Set note = session.DocumentContext

If note Is Nothing Then dbug.LogAction("note is not set") Else dbug.LogAction("note is set")

REM Note the Subject of all messages

dbug.LogAction("Subject ->" + note.Subject(0))



If Instr(1,note.Subject(0), "CompA") <> 0 Then

	categ="CompA"

Elseif Instr(1,note.Subject(0), "CompB") <> 0 Then

	categ="CompB"

Else

	Print note.Subject(0)

	Exit Sub

End If



Set rtitem = note.GetFirstItem( "Body" )



If ( rtitem.Type = RICHTEXT ) Then		

’ NO FILE ATTACHMENTS

	If note.HasEmbedded = False Then

		Print categ + db.Title + " - Agent ("+n+") error : sent email has no attachments"

		Set memodoc = New NotesDocument(db)

		memodoc.Importance = "1" ' *** Sets Importance to High

		memodoc.Principal=db.Title

		memodoc.Subject="ERROR: " + db.Title+ " Agent Error (" +categ+")"

		Set ertitem = New NotesRichTextItem( memodoc, "Body" ) 

		Call ertitem.AppendText(db.Title + " - Agent ("+n+") error : " & Err() & " : " & Error())

		Call memodoc.Send( False, "dBGroup" )

		Exit Sub

	Else

		

		Forall o In rtitem.EmbeddedObjects

			If ( o.Type = EMBED_ATTACHMENT )  Then

				oname$=o.Name

				Call o.ExtractFile ( "\\svr$\dir$" & oname$)

				dbug.LogAction("extract file")				

				note.Category=categ

				note.FileDate=Filedatetime("\\svr$\dir$\" & oname$)

				Call note.Save( True, False )

’ FILE FOUND AND EXTRACTED

				Set memodoc = New NotesDocument(db)

’ memodoc.Form=“Memo”

				memodoc.Principal=db.Title

				memodoc.Subject=db.Title+ " Agent completed successfully (" +categ+")"

				Set ertitem = New NotesRichTextItem( memodoc, "Body" ) 

				Call ertitem.AppendText("Agent ("+n+") completed successfully >> ")

				Call ertitem.AppendDocLink(note, note.Subject(0) )

				Call memodoc.Send( False,"User1")

				Print "Doc Database - Agent ("+n+") completed successfully"			

			End If	

			Exit Sub

			

		End Forall

	End If

End If



dbug.LogAction("done")

dbug.Close 	

Exit Sub

errtrap:…

No errors are generated BTW

Subject: Possible Code Regression Found… Any thoughts for workarounds?

I wonder if you are sending this to a mail-in database? ewe had just this problem, and went to the mail-in database definition document. I discovered that it as an option for mail preference - Rich Text or MIME. I had not noticed this before - maybe it was added in 7.0.3?

Subject: RE: Possible Code Regression Found… Any thoughts for workarounds?

I’m pretty sure this a bug.

session.convertmime simply doesn’t work in Before Mail agents — and it used to.

It’s definitely a Regression in 8.0.1 and is fixed in 8.0.2

see this:

http://www-10.lotus.com/ldd/nd8forum.nsf/5f27803bba85d8e285256bf10054620d/0dfcdfe2817c9d138525749e0002b0a3?OpenDocument&Highlight=0,convertmime