AttachFile Method (CDONTS NewMail Object)

The AttachFile method adds an attachment to the message by reading a file.

Syntax

objNewMail.AttachFile(Source [, FileName] [, EncodingMethod] ) 
 
objNewMail
Required. This NewMail object.
Source
Required. IStream object or String. The full path and file name of the file to be attached to the message, or a pointer to an IStream object containing the file data.
FileName
Optional. String. The file name to appear in the attachment's placeholder in the message. If FileName is not supplied, the file name from the Source parameter is used.
EncodingMethod
Optional. Long. The manner of encoding the attachment. The following values are possible:
EncodingMethod setting Value Description
CdoEncodingUUencode 0 The attachment is to be in UUEncode format (default).
CdoEncodingBase64 1 The attachment is to be in base 64 format.

Remarks

The default value for the EncodingMethod parameter can change if you set the MailFormat property. If MailFormat is set to CdoMailFormatText, the default value is CdoEncodingUUencode. If MailFormat is set to CdoMailFormatMime, the default value is CdoEncodingBase64. However, if you add an attachment encoded in base 64 format, the value of the MailFormat property is automatically set to CdoMailFormatMime.

Only C/C++ and Java programs can use an IStream object for the Source parameter. They should pass an IUnknown object that returns an IStream interface in response to QueryInterface. Microsoft® Visual Basic® supports the IDispatch interface and not IUnknown, so it cannot use an IStream object.