Notes email attachment to IFS Agent?

Is there a class, or function of some kind that can be used to authenticate against an AS400 IFS using lotus Script.

What we have is a method to extract email attachments and move them to a user’s local machine, but it is a manual process.

We need is an agent that will automatically strip out the attachment and place it on the iSeries IFS, but we keep running into authenticate.

I saw “LCConnection” but that gets you right into a DB, and not the IFS.

Does anyone have a suggestion?

Subject: authenticate

Can’t you add QNOTES to the authorization list controlling the directory where you wish to place the stream file?

Subject: Different Box

I tried that, but it didn’t work.

May be because Domino is on one iSeries Box, and the IFS I’m trying to get to is on another iSeries Box.

pluse, the code is looking for a UNC “\iSeries\sharefolder\foldertype\foldername”

It works when I run t in a clinet, manually as an action menu option… but then I think it is using my Winbows access, which is the same as AS400 access.

Subject: qnotes on target box?

Is user QNOTES on the target box?

You could change to a different user profile but you’re writing to stream files and not DB2 so “adopting authority” doesn’t work as nice. Now you’re talking about “profile handles”.

http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/apis/sec1.htm

Subject: yes… he is on the target box

Yes… QNOTES is on the target box. I set him up with access all the way through the path.

Still no luck

Subject: some more options

I haven’t done it in a long time, but you can use the QSNADS subsystem to copy files to the IFS of a separate System i using Netserver. You would add QNOTES as a user in Active Directory, then link to the second IFS using the QSNADS proxy. That tends to be horribly slow, though, and getting it all set up is tricky. I don’t remember all the particulars anymore.

Another way is to use SNDNETF, which lets you specify a userid. You can execute OS/400 commands from the LotusScript Shell() function. http://forums.systeminetwork.com/isnetforums/showthread.php?t=49521

It might be cleaner to just use FTP, again via Shell(). Admin Alert: Making OS/400 Automatically FTP to Windows - IT Jungle

Why are you copying it to the IFS on a separate System i anyway? Does it have Netserver set up already and users have mapped drives or something?

Subject: Why I have to move them

I’m moving the files to the other iSeries box becuase that is where images (such as these attachments) are scanned on to a laser disc.

The other box, runs everythis AS400, and the source box runs everything Domino (email, web server, quickr, sametime)

Subject: QFileSvr.400

Have you tried just writing to QFileSvr.400?See WRKLNK ‘/QFileSvr.400/remotei/*’

Subject: Given up on remote IFS, but local IFS fails too…

I have given up on trying to move the file to another box, and will settle for getting the attachments in the IFS of the Domino Box… but I keep getting a

“Error creating product object”

Error when it runs.

Here’ what I’m using as an agent:

Dim sDir As String

Dim s As NotesSession

Dim w As NotesUIWorkspace

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Sub Initialize

Set s = New NotesSession

Set w = New NotesUIWorkspace 

Set db = s.CurrentDatabase

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument

Dim rtItem As NotesRichTextItem

Dim RTNames List As String

Dim DOCNames List As String

Dim itemCount As Integer

Dim sDefaultFolder As String

Dim x As Integer

Dim vtDir As Variant

Dim iCount As Integer

Dim j As Integer

Dim lngExportedCount As Long

Dim attachmentObject As Variant



sDir = "/CustImport/CustomerFiles"

’ Msgbox sDir

While Not ( doc Is Nothing )

	

	iCount = 0

	itemCount = 0

	lngExportedCount = 0

	Erase RTNames

	Erase DocNames

	

	'Scan all items in document

	Forall i In doc.Items

		

		If i.Type = RICHTEXT Then

			Set rtItem = doc.GetfirstItem(i.Name)

			If Not Isempty(rtItem.EmbeddedObjects) 	Then

				RTNames(itemCount) = Cstr(i.Name)

				itemCount = itemCount + 1

			End If

		End If

		

	End Forall  

	

	For j = 0 To itemCount - 1 

		Set rtItem = Nothing

		Set rtItem = doc.GetfirstItem(RTNames(j))

		Forall Obj In rtItem.EmbeddedObjects

			If (Obj.Type = EMBED_ATTACHMENT) Then

				Call ExportAttachment(Obj)

				Call Obj.Remove

				Call doc.Save(False, True) 

			'creates conflict doc if conflict exists

			End If 

		End Forall 

	Next

	

	'Scan all items in document

	Forall i In doc.Items

		

		If i.Type = ATTACHMENT Then

			DOCNames(lngExportedCount) = i.Values(0)

			lngExportedCount = lngExportedCount + 1

			

		End If

		

	End Forall

	

	For j% = 0 To lngExportedCount -1 

		Set attachmentObject = Nothing 

		Set attachmentObject = doc.GetAttachment(DOCNames(j% ))

		Call ExportAttachment(attachmentObject)   

		Call attachmentObject.Remove   

		Call doc.Save(False, True) 

		'creates conflict doc if conflict exists

	Next  

	

	Set doc = dc.GetNextDocument(doc)

Wend



Msgbox "Export Complete.", 16, "Finished"

End Sub

Sub ExportAttachment(o As Variant)

Dim sAttachmentName As String

Dim sNum As String

Dim sTemp As String



sAttachmentName = sDir & "/" & o.Source

Print "The filename path is " &  sAttachmentName



While Not (Dir$ (sAttachmentName, 0 ) = "" ) 

	sNum = Right (Strleftback(sAttachmentName, "."), 2)

	If Isnumeric(sNum) Then

		sTemp = Strleftback(sAttachmentName, ".")

		sTemp = Left(sTemp, Len(sTemp) - 2)

		sAttachmentName = sTemp & Format$ ( Cint (sNum) + 1, "##00" ) & "." & Strrightback(sAttachmentName, ".")

	Else

		sAttachmentName = Strleftback(sAttachmentName, ".") & "01." & Strrightback(sAttachmentName, ".")

	End If

Wend



Print "Exporting " & sAttachmentName

'Save the file

Call o.ExtractFile( sAttachmentName ) 

End Sub

Subject: where do you get the error?

Which line is causing the error?

Subject: Can’t really tell…

I wish I could say for sure.

I see that error in the log.nsf file. It seems to make it to the ExportAttcahment sub but dies there.

If I run it form the Designer, I get a “path not found” in the “ExportAttcahment” sub, but I would expect that since the path is on the iSeries box, and not my local workstation.

Is here a way to try to debug it from the iSeries point of view?

Subject: you can use an agent log

I’ll assume this is running as either a triggered or scheduled agent. You can use an agent log to capture output and help track down where the errors are happening.

Subject: Found the problem…

I found the solution is a discussion at:

http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/92d1e77deee51ded85256c4f004e363b?OpenDocument

This issue was that with initial process used an action item to trigger the event. But I wanted to use it as a background agent.

Even though I was not calling for any UI objects, they were being set (because they were originally used in the action item) at:

Dim w As NotesUIWorkspace

Set w = New NotesUIWorkspace

I removed these two lines and it began to work as expected.