[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Lotus 6, how do I set up a document to automatically upload an attachment from a folder?

I haven't created the form yet but can anyone give me the steps and code?  I want to run an agent every 8 hours to upload create a document and attach an attachment.  
0
sjmmajor
Asked:
sjmmajor
  • 8
  • 7
1 Solution
 
madheeswarCommented:
u should maintain a log to monitor if the agent has run in last 8 hours.
And maintain a Static folder to attach and place the path of the folder in the agent.
and also, how many files will be placed in that folder?

thanks
0
 
Sjef BosmanGroupware ConsultantCommented:
Madheeswar, this must a job for your company Rent-A-Coder Inc. at 500 points :) You must have the exact example in your toolbox somewhere. Btw, I think Sjmmajor is not talking about Notes folders, but a directory on disk.

What my approach would be: create an agent that runs every hour but only uploads every 8 hours. It will use a profile document to store the current time and the time it last performed an upload. If more than 8 (or 7.5) hours passed since, the actual upload will take place. The uploading and attaching is not very difficult, see the EmbedObject method in the NotesRichTextItem class.
0
 
sjmmajorAuthor Commented:
sjef bosman you are right.  I want it to come from a directory on disk.  I see the code but where does this code reside, in the Agent?
0
Independent Software Vendors: 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!

 
Sjef BosmanGroupware ConsultantCommented:
In an agent, yes, to be called from the Initialize event. What is it that you want to do exactly, always the same file, to always the same document or each time a new one? What are your spec's?
0
 
sjmmajorAuthor Commented:
I am getting action failed.  Query is not understandable.  Here is the code I used in my agent.

                Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim rtitem As NotesRichTextItem
      Dim object As NotesEmbeddedObject
      Set db = session.CurrentDatabase
      Set doc = New NotesDocument (db)
      Set rtitem = New NotesRichTextItem (doc,"Body")
      Set object = rtitem.EmbeddedObjects(EMBED_ATTACHMENT,"", "C:\jobchanges\testdoc.XLS")
      DOC.FORM = "Main Topic"
      doc.Subject = "Here is the test document"
      Call doc.save(True,True)
I think this one creates the field in the document.  I just would like to update the field in the document.
0
 
Sjef BosmanGroupware ConsultantCommented:
Very near!

Set object = rtitem.EmbeddedObjects(EMBED_ATTACHMENT,"", "C:\jobchanges\testdoc.XLS")

There is EmbeddedObjects, but you have to use EmbedObject

Sjef :)
0
 
sjmmajorAuthor Commented:
I am still getting the same error. Is there something else on the agent that I should be doing?  I appreciate your help!
0
 
Sjef BosmanGroupware ConsultantCommented:
You know that you can run an agent manually, from the LotusScript Debugger? Did you define EMBED_ATTACHMENT, or include the file lsconst.lss?
0
 
sjmmajorAuthor Commented:
Where would I define Embed_attachment?  I did turn on the debugger and I ran the agent manually in the view but the agent didn't show me line by line like I would think a debugger would.  It still showed the same error message at the bottom.

I know I must be missing something.  Is there something I have to do in the form?

0
 
Sjef BosmanGroupware ConsultantCommented:
You can do three things to make it work:
- use plain 1454
- define EMBED_ATTACHMENT as
    Const EMBED_ATTACHMENT= 1454
- use an include in the options or declarations section:
    %include "LSCONST.LSS"

That is, if that's the error. Did you set, in the Options section:
    Option Declare
This will ensure that you have to declare EVERY global variable. In R6 you can set this as default setting. What happens if you didn't set it: EMBED_ATTACHMENT will have the value 0!

To use stepping in the Debugger, either click on Step Into all the time, or use F8.
0
 
sjmmajorAuthor Commented:
I must be brain dead today.  Do I define that in the form or the agent?
0
 
Sjef BosmanGroupware ConsultantCommented:
There is no form involved, unless I'm terribly mistaken. The only form you might need is to open the document that the agent created. If that's what is supposed to be happening. For the time being, just replace EMBED_ATTACHMENT by 1454 and see if it works. Polishing up comes later.
0
 
sjmmajorAuthor Commented:
I finally got that part.  Wow!  Now it is giving me the error "Unexpected: Const, Expected: Data Type New"

It does create the document and I can open it but it gives me that error while opening it.

0
 
sjmmajorAuthor Commented:
I got it!!  But for some reason it doesn't open an HTM file.  It will for a regular excel file.  I can open another question for the points.  

You have been a big help!  
0
 
Sjef BosmanGroupware ConsultantCommented:
I wouldn't know if an HTM file were treated differently from any other file. Seems a bit odd to me. Try again, with a fixed named file in a known directory, first as filename.txt, then as filename.htm.
0
 
sjmmajorAuthor Commented:
Sorry I thought I had closed this out.  Thanks sjef bosman for all your help!! It is working great!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now