VBScript の場合、このメソッドの引数は、数値インデックス (itemNum) か表示名 (displayName) のいずれでもかまいません。Perl の場合、引数は数値インデックスでなければなりません。
Count および Item メソッドを使用すると、このメソッドを呼び出す前に正しい Attachment オブジェクトを特定できます。
VBScript
attachments.Delete itemNum attachments.Delete displayName
Perl
$attachments->Delete(itemNum);
VBScript
' This example assumes there is at least 1 attachment field in this record type, ' and at least one attachment associated with this record. ' NOTE: The entity must be in an editable state to delete an attachment -- see above. set currentSession = GetSession set attachFields = AttachmentFields set attachField1 = attachFields.Item(0) set theAttachments = attachField1.Attachments If Not theAttachments.Delete(0) Then OutputDebugString "Error deleting the attachment." End If
Perl
# This example assumes there is at least 1 attachment field in this record type, # and at least one attachment associated with this record. # NOTE: The Entity must be in an editable state to delete an attachment -- see above. # 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 $attachments = $attachfield1->GetAttachments(); # Delete the first attachment if (!$attachments->Delete(0)) { $session->OutputDebugString("Error deleting attachment from record.¥n"); }