AddAttachment

Description

Adds an Attachment object to the collection.

Note: This method is for Perl only.

This method creates a new Attachment object for the file and adds the object to the end of the collection. You can retrieve items from the collection using the Item method.

Syntax

Perl


$attachments->AddAttachment(filename, description); 
Identifier
Description
attachments
An Attachments collection object, representing the set of attachments in one field of a record.
filename
A String containing the absolute or relative pathname of the file to be attached to this field.
description
A String that contains arbitrary text describing the nature of the attached file.
Return value
A Boolean that is True if the file was added successfully, otherwise False.

Example

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");
 }