AddAttachment Method

AddAttachment Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Adds an attachment to this message.

Applies To

IMessage Interface

IWorkflowMessage Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

[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 );

Parameters

  • 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 HTTP. This name can be used to set the credentials for basic, NTLM, and Negotiate (Kerberos) authentication packages.
  • Password
    An optional password to use for authentication when retrieving the resource using HTTP. This password can be used to set the credentials for basic, NTLM, and Negotiate (Kerberos) authentication packages.
  • pVal
    Returned reference to an IBodyPart Interface.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The AddAttachment method adds the attachment by first retrieving the resource specified by the 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 Universal Naming Convention (UNC) paths.

The MIMEFormatted property determines how the attachment is formatted when the message is serialized for delivery to a 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 Unix-to-Unix encode (UUENCODE) 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 HTTP from a server that requires client authentication. If the Web server supports only the basic mechanism, 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 alternative credentials with the UserName and Password parameters.

Example

[Visual Basic]

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

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.