HOWTO: Embed a Document in a Message Using CDO (1.x) |
Q169031
Using CDO (1.x), it is possible to embed a file in a message so that the contents of the file are viewed when the message is opened--for example, embedding a bitmap into the message so that the actual bitmap appears when you open the message.
The code provided is a sample of performing this task in Microsoft Visual Basic.
Dim oSession As Object
Set oSession = CreateObject("MAPI.Session")
oSession.Logon
Dim oMessage As Object
Set oMessage = oSession.Outbox.Messages.Add
Dim oAttachment As Object
Set oAttachment = oMessage.Attachments.Add
If oAttachment Is Nothing Then
MsgBox "Unable to create new Attachment object"
Stop
End If
'Specify where to place the attachment in the message
oAttachment.Position = 1
' Active Messaging 1.0
oAttachment.Type = mapiOle
' Active Messaging 1.1
oAttachment.Type = ActMsgOle
oAttachment.Source = "Paint.Picture"
oAttachment.ReadFromFile "c:\test.bmp"
oMessage.Update
'Goto the next line if an error occurs on the Send (usually
'caused by the user cancelling the message)
On Error Resume Next
'Set ShowDialog to True because we have not set
'the Recipient for the message
oMessage.Send ShowDialog:=True
oSession.Logoff
Type property Source property
---------------- ---------------------------------------------
ActMsgFileData Specifies the full path of the file that will
be attached when the ReadFromFile method is
called later. It is not necessary to set this
property if the source is specified in the call
to the Add method of the Attachments
collection.
ActMsgFileLink Specifies a full path name in a universal
naming convention (UNC) format, such as
\\Sales\Info\Product\News.doc.
ActMsgOLE Specifies the registered OLE class name of the
attachment, such as Word.Document or
PowerPoint.Show. The actual file contents would
be loaded with the ReadFromFile method.
ActMsgEmbeddedMessage Specifies the unique identifier of the message
to be embedded; returns the embedded Message
object.
For additional information about Collaboration Data Objects (1.x) versus Active Messaging, please see the following article in the Microsoft Knowledge Base:
Q176916 INFO: Active Messaging and Collaboration Data Objects (1.x)Microsoft Developer Network, Platform SDK, "Source Property (Attachment Object)"
Additional query words:
Keywords : kbcode kbActMsg kbCDO100 kbCDO110 kbCDO120 kbCDO121 kbMsg kbOLEMsg kbGrpDSMsg
Issue type : kbhowto
Technology : kbAudDeveloper kbCDOsearch kbExchangeSearch kbCDO100a kbCDO110 kbCDO120 kbCDO121
|
Last Reviewed: April 29, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |