|
RDOAttachments object collection |
RDOAttachments collection represents
the attachments of a message.
Returned by:
RDOMail.Attachments
The example below connects to the
MAPI session used by Outlook, retrieves a message using the entry id of a give
Outlook Object Model message, and prints out all the attachment names.
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Mail = Session.GetMessageFromID(MailItem.EntryID)
for each att in Mail.Attachments
debug.print att.filename
next |
|
Derived from:
IDispatch
|
|
Properties |
|
Count |
integer. Returns the number
of attachments in the collection |
|
_Item(Index) |
Index -
integer. A default object property.
Retrieves an attachment with
a given index (1 to Count).
Returns
RDOAttachment object |
|
RawTable |
IUnknown, read-only. Returns the IMAPITable Extended MAPI interface
(as returned by IMessage::GetAttachmentTable in Extended MAPI) used
internally by the RDOAttachments collection |
|
Session |
RDOSession, read-only. Returns the parent
MAPI session represented by the RDOSession object
|
|
MAPITable |
MAPITable, read-only. Returns the
MAPITable Redemption object which can be used to manipulate the
collection (restrict, find, etc).
|
|
Parent |
Returns the parent
RDOMail object |
|
|
Methods |
|
Item(Index) |
Index -
integer.
Retrieves an attachment with
a given index (1 to Count).
Returns
RDOAttachment object |
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Mail = Session.GetMessageFromID(MailItem.EntryID)
for i = 1 to Mail.Attachments.Count
debug.print Mail.Attachments.Item(i).filename
next |
Add(Source, Type,
Position, DisplayName) |
Adds a new attachment.
Returns RDOAttachment object.
Source - can be either
1. String specifying the fully qualified path to the file to be attached
(fully qualified HTTP or HTTPS urls are allowed). An error will be
raised if the file does not exist or cannot be accessed.
Both olByValue and olOle type
attachments (Type parameter) can be created.
2. Message (RDOMail
object).
3. Attachment from another message (RDOAttachment
object).
4. Variant array of bytes (assumed to be the raw attachment
data). Both olByValue and olOle type attachments (Type parameter) can be
created.
RDOAttachment.FileName
parameter will then need to be set for the olByValue attachments.
5. IStream COM interface.
Both olByValue and olOle type
attachments (Type parameter) can be created. The RDOAttachment.FileName
parameter will then need to be set the olByValue attachments.
6. IStorage COM interface.
Only olOle type attachments
can be created for IStorage source objects.
Type - integer,
optional. One of the OlAttachmentType enums - olByValue (1),
olByReference (4), olEmbeddeditem (5)
Position - integer,
optional. Position of the attachment in the message body. Only applies
to the messages in the RTF format.
DisplayName - string,
optional. Attachment display name. Warning - as of Outlook 2002 SP3,
Outlook always displays the file name instead of display name for
security reasons. |
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Inbox = Session.GetDefaultFolder(olFolderInbox)
set Drafts = Session.GetDefaultFolder(olFolderDrafts)
set Mail = Drafts.Items.Add
'add a message
Mail.Attachments.Add Inbox.Items(1)
'add a file
Mail.Attachments.Add "c:\temp\test.doc"
'add a variant array of bytes -
'create a TXT file attachment with
"test" inside Dim
AttachData(3)
AttachData(0) = Asc("t")
AttachData(1) = Asc("e")
AttachData(2) = Asc("s")
AttachData(3) = Asc("t")
set Attach = Mail.Attachments.Add(AttachData)
Attach.FileName = "test.txt"
'all done, save the message
Mail.Save |
Remove(Index) |
Removes an attachment with an
index given by the Index parameter (integer, 1 through Count). |
|
Clear |
Removes all attachments from
the message |
|
GetFirst |
Returns the first
attachment in the collection. Returns Nothing if no first attachment exists, for example, if there are no
attachments. |
|
GetLast |
Returns the last attachment
in the collection. Returns Nothing if no last attachment exists, for example, if there are no
attachments. |
|
GetNext |
Returns the next attachment
in the collection. It returns Nothing if no next
attachment exists, for example, if already positioned at the end of the
collection. |
|
GetPrevious |
Returns the previous
attachment in the collection. It returns Nothing if no
previous attachment exists, for example, if already positioned at the
beginning of the collection. |
|
|