AttachFile Method  
 

Attach the specified file to the current message.

Syntax

object.AttachFile( FileName, [Options] )

Parameters

FileName
A string that specifies the name of the file to be attached to the message. If the string is empty or the file does not exist, an error will be returned.
Options
An integer value that specifies the type of encoding that will be applied to the attachment. If this argument is not specified, then text files will not be encoded and binary files will be encoded using the standard base64 algorithm.
Value Constant Description
0 mailAttachDefault The file attachment encoding is based on the file content type. Text files are not encoded, and binary files are encoded using the standard base64 algorithm. This is the default option for file attachments.
1 mailAttachBase64 The file attachment is always encoded using the standard base64 algorithm, even if the attached file is a plain text file.
2 mailAttachUucode The file attachment is always encoded using the standard uuencode algorithm, even if the attached file is a plain text file.
3 mailAttachQuoted The file attachment is always encoded using quoted-printable encoding. Note that this encoding method is only recommended for text content, typically either as HTML or RTF.

Return Value

A value of zero is returned if the method succeeds. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

The AttachFile method attaches the specified file to the current message. If the message already contains one or more file attachments, then it is added to the end of the message. If the message does not contain any attached files, then it is converted to a multipart message and the file is appended to the message.

See Also

ContentType Property, AttachData Method, ExtractFile Method