Position Property (Attachment Object)

The Position property returns or sets the position of the attachment within the text of the message. Read/write.

Syntax

objAttachment.Position

Data Type

Long

Remarks

The Position property is a long integer describing where the attachment should be displayed in the message text. The attachment overwrites the character present at that position. Applications cannot place two attachments in the same location within a message, and attachments cannot be placed beyond the end of the message text.

A positive value of Position represents an index to the character within the message text to be replaced by the attachment. The first text character has an index of 1. The value 0 indicates that the attachment is present but should not be made visible in the displayed message. The value –1 indicates that the attachment is not handled using the Position property.

CDO does not manage the actual display of the attachment within the message. The Position property simply provides a location for the displaying application, which must find and replace the appropriate character in the message's Text property.

The Position property can also be set at the time of creation of the attachment by supplying the position parameter to the Add method of the Attachments collection.

The Position property corresponds to the MAPI property PR_RENDERING_POSITION. It can be rendered into HTML hypertext using the CDO Rendering ObjectRenderer object. To specify this, set the object renderer's DataSource property to this Attachment object and the property parameter of the RenderProperty method to CdoPR_RENDERING_POSITION.

Note The MAPI rendering position is zero-based, meaning that the first character in the message text is considered to be at position zero. All CDO string indexes, including the Position property, are one-based. If you render the Position property into HTML, the MAPI value is used for the rendering instead of the CDO value. This could potentially lead to confusion regarding which message text character is to be replaced with the attachment.

Example

' from the function Attachments_Add() 
    Set objAttach = objAttachColl.Add ' add an attachment 
    With objAttach 
        .Type = CdoFileLink 
        .Position = 0 ' place at beginning of message 
        .Source = "\\server\bitmaps\honey.bmp" ' UNC name 
    End With 
    ' must update the message to save the new info 
    objOneMsg.Update ' update the message 
    MsgBox "Added an attachment of type CdoFileLink"