Load

Descrizione

Scrive il contenuto dell'oggetto nel file specificato.

È possibile utilizzare questo metodo per estrarre un file allegato dal database e salvarlo nel file system locale. Se un file con lo stesso nome esiste già nel percorso specificato del parametro filename, tale file deve essere scrivibile e il relativo contenuto esistente verrà sostituito. Il file estratto non è un file temporaneo; esso permane dopo che il processo avrà terminato di utilizzare questa API.

Sintassi

VBScript

attachment.Load filename 

Perl

$attachment->Load(filename); 
Identificativo
Descrizione
attachment
Un oggetto Attachment che rappresenta l'allegato di un file in un record.
filename
Una stringa contenente il nome del percorso del file che si desidera scrivere. Questo nome del percorso può essere un percorso assoluto o relativo.
Valore di ritorno
Un valore True booleano se l'operazione ha avuto esito positivo, in caso contrario restituisce un valore False booleano.

Esempi

VBScript

' This example assumes there is at least 1 attachment field 
' and 1 attachment associated with the record. 
set currentSession = GetSession
set attachFields = AttachmentFields 
set attachField1 = attachFields.Item(0) 
set theAttachments = attachField1.Attachments 
x = 1
For each attachment in theAttachments 
   thefileName = "C:\attach" & x & ".txt" 
   x=x+1
'  Write the file
   status = attachment.Load (thefileName)
Next 

Perl

# This example assumes that there is at least 1 attachment
# field associated with the record. Otherwise, 
# GetAttachmentFields won't return anything interesting 
# and an error would be generated

# Get the collection of attachment fields
$attachfields = $entity->GetAttachmentFields();

# Get the first attachment fields
$attachfield1 = $attachfields->Item(0)

# Now get the collection of attachments from the attachments field
$attachments = $attachfield1->GetAttachments();

# Retrieve the number of attachments for the for loop
$numattachments = $attachments->Count();

for ($x = 0 ; $x < $numattachments ; $x++)
 {
 # Retrieve the correct attachment
 $attachment = $attachments->Item($x);

 # Select a filename to write to
 $filename = "C:\\attach".$x.".txt";

 # Write the file
 $status = $attachment->Load($filename);
 } 

Feedback