Platform SDK: Exchange 2000 Server

AddAttachment Method

[This is preliminary documentation and subject to change.]

Adds an attachment to this message.

[Visual Basic]
Function AddAttachment(
    ByVal URL as String, 
   [ByVal UserName as String], 
   [ByVal Password as String]
) as IBodyPart
[C++]
HRESULT AddAttachment(
   BSTR URL,
[BSTR UserName,]
  [BSTR Password,]
   IBodyPart** pVal
);
[IDL]
HRESULT AddAttachment(
   [in] BSTR URL, 
   [in, optional] BSTR UserName, 
   [in, optional] BSTR Password, 
   [out,retval] IBodyPart** pVal
);
URL
The full path and file name of the message to be attached to this message.
UserName
An optional user name to use for authentication when retrieving the resource using Hypertext Transfer Protocol (HTTP). This name can be used to set the credentials for basic, digest, NTLM, and Negotiate (Kerberos) authentication packages.
Password
An optional user name to use for authentication when retrieving the resource using Hypertext Transfer Protocol (HTTP). This password can be used to set the credentials for basic, digest, NTLM, and Negotiate (Kerberos) authentication packages.

Remarks

The AddAttachment method adds the attachment by first retrieving the resource specified by the Uniform Resource Locator (URL) and then adding the content to the message's Attachments collection within a BodyPart object.

The URL prefixes supported in the URL parameter are file://, ftp://, http://, and https://. The default prefix is file://. This facilitates designation of paths starting with drive letters and of universal naming convention (UNC) paths.

The MIMEFormatted property determines how the attachment is formatted when the message is serialized for delivery to a Simple Mail Transfer Protocol (SMTP) service. If this property is set to True, the attachment is formatted using Multipurpose Internet Mail Extensions (MIME). If the property is set to False, the attachment is added to the serialized content stream in Uuencoded format.

If you populate the HTMLBody property before calling the AddAttachment method, any inline images are displayed as part of the message.

Use the UserName and Password parameters when you are requesting Web pages using the Hypertext Transfer Protocol (HTTP) from a server that requires client authentication. If the Web server supports only the basic or digest authentication mechanisms, these credentials must be supplied. By default the current process security context is used to authenticate when using the NTLM or Negotiate (Kerberos) security packages; however, you can specify alternate credentials with the UserName and Password parameters.

Example

Dim iMsg as New CDO.Message 
Dim iBp as CDO.IBodyPart
Set iBp = iMsg.AddAttachment("http://example.microsoft.com") 
Set iBp = iMsg.AddAttachment("c:\myfiles\file.doc")
' ..
iMsg.Send