This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 30, 2011, 9:10 AM
9 Posts
topic has been resolvedResolved

How do I get the extractFile() method to accept a quoted string?

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer,Administrator
  • Tags:
  • Replies: 2
My app is sending out formatted email messages to selected users (picked from a view control) and I have several file attachments added to each message.
 
In development my files are stored in a temporary directory on the server and referenced explicitly by path & name. This all works. 
 
What I'd like to be able to achieve is to get the relevant file attachments from another document held within the same database, either copy directly to my new document prior to mailsend or extract to filesystem, grab & attach to new doc and then clean up afterwards. Is this possible? Does anyone have example code they would be willing to share? 
 
Thanks Keith Adley
Mar 30, 2011, 8:49 PM
9 Posts
Re: Accessing file attachments stored in richtext field
Through an amount of brute-force & ignorance I have solved my first problem and I can now reference all the files attached to my document and extract the file names. I can even take one of those files and attach it to my outbound email message. What I can't yet do it to is get the extractFile method to accept a variable name so that I can process it in a loop.
 
if (document1.getAttachmentList("Body").isEmpty()){
attachmentNames = "No Files Yet";
} else {
var v = document1.getAttachmentList("Body");

for (i=0; i < v.length; i++){
var eo:NotesEmbeddedObject = v.get(i);
attachmentNames = attachmentNames + eo.getName();
var att1:NotesEmbeddedObject = courseDoc.getAttachment(eo.getName());
filepath$ = "d:\\temp\\xsp\\" + attachmentNames;
 
att1.extractFile(filepath$); <======= if I use a var here it doesn't work, if I code the name explicitly it works fine

sessionScope.put("att"+i,eo.getName());
}
}
 
Generates the error Script interpreter error, line=15, col=6: [TypeError] Exception occurred calling method NotesEmbeddedObject.extractFile(string) null
 
I've tried various ways to build the variable but no luck yet. Any clues???? 
Mar 31, 2011, 9:55 AM
9 Posts
Re: Accessing file attachments stored in richtext field
 Solved - thank heavens for Google!!
 
if (document1.getAttachmentList("Body").isEmpty()){
attachmentNames = "No Files Yet";
} else {
var v = document1.getAttachmentList("Body");

for (i=0; i < v.length; i++){
var eo:NotesEmbeddedObject = v.get(i);
attachmentNames = attachmentNames + eo.getName();
var att1:NotesEmbeddedObject = courseDoc.getAttachment(eo.getName());
att1.extractFile("D:\\temp\\" + eo.getName());       <============= Dumb blindness prevented me from seeing the obvious

sessionScope.put("att"+i,eo.getName());
}

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal