AddAttachment

Descrizione

Aggiunge un oggetto Attachment alla raccolta.

Nota: questo metodo è disponibile solo per Perl.

Questo metodo crea un nuovo oggetto Attachment per il file e aggiunge l'oggetto alla fine della raccolta. È possibile richiamare elementi dalla raccolta con l'utilizzo del metodo Item.

Sintassi

Perl

$attachments->AddAttachment(filename, description); 
Identificativo
Descrizione
attachments
Un oggetto Attachments, che rappresenta la serie di allegati in un campo di un record.
filename
Una stringa contenente il nome del percorso (pathname) assoluto o relativo del file da allegare a questo campo.
description
Una stringa contenente il testo arbitrario che descrive la natura del file allegato.
Valore di ritorno
Un valore True booleano se il file è stato aggiunto correttamente, in caso contrario un valore False booleano.

Esempio

Perl

# This example assumes that there is at least
# one attachment field associated with the record
# For this entity record, get the collection of all
# attachment fields

$attachfields = $entity->GetAttachmentFields();

# Work with the first attachment field

$attachfield1 = $attachfields->Item(0);

# For this attachment field, get the collection of all
# its attachments

$theAttachments = $attachfield1->GetAttachments();

# Add the designated file and description to the 
# attachments field

if (!$theAttachments->AddAttachment("c:\\attach1.txt","attachment description"))
 {

$session->OutputDebugString("Error adding attachment to record.\n");
 } 

Feedback