Skip to Content
CDO & MAPI Programming with Visual Basic:
book

CDO & MAPI Programming with Visual Basic:

by Dave Grundgeiger
October 2000
Intermediate to advanced
384 pages
10h 22m
English
O'Reilly Media, Inc.
Content preview from CDO & MAPI Programming with Visual Basic:

Sending File Attachments

MAPI defines four types of attachments: file, reference to a file, OLE object, and embedded message.

CDO handles all four types of attachments easily. To add an attachment to a message, use the Add method of the Message object’s Attachments collection:

' (CdoMessage previously Dim'ed and Set)

Dim CdoAttachments As MAPI.Attachments
Dim CdoAttachment As MAPI.Attachment

Set CdoAttachments = CdoMessage.Attachments
Set CdoAttachment = CdoAttachments.Add(Name:="autoexec.bat", _
   Position:=-1, Type:=CdoFileData, Source:="c:\autoexec.bat")

The syntax of the Add method is:

Set CdoAttachment = CdoAttachments.Add([Name][, Position][, Type][, Source])

The method returns a reference to the newly created Attachment object. The method’s parameters are:

Name

The display name to be used by the receiving mail client when representing the attachment in its UI. When the attachment is a file, the name should be the filename, including its extension. The receiving mail client may default to this name when copying the data from its message store to the local file system. (Some clients may instead default to the filename portion of the Source parameter.)

Position

The character position within the body of the message at which the attachment should appear. Some email client applications display a representation of the attachment within the body of the message at the character position indicated by Position. (However, some ignore this value and display the attachments separately.) ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel® 2007 VBA Programmer's Reference

Excel® 2007 VBA Programmer's Reference

John Green, Stephen Bullen, Rob Bovey, Michael Alexander
COM Programming with Microsoft® .NET

COM Programming with Microsoft® .NET

John Paul Mueller, Julian Templeman

Publisher Resources

ISBN: 156592665XSupplemental ContentCatalog PageErrata