|
Attach the contents of a buffer to the current message.
Syntax
object.AttachData( Buffer, [Length],
[ContentName], [ContentType], [Options] )
Parameters
- Buffer
- A string or byte array which specifies the data to be attached
to the message. If an empty string is passed as the argument, no
data is attached, but an additional empty message part will be
created.
- Length
- An integer value which specifies the number of bytes of data in
the buffer. If this value is omitted, the entire length of of the
string or size of the byte array is used.
- ContentName
- An optional string argument which specifies a name for the data
being attached to the message. This typically is used as a file
name by the mail client to store the data in. If this parameter is
omitted or passed as an empty string then no name is defined and
the data is attached as inline content. Note that if a file name is
specified with a path, only the base name will be used.
- ContentType
- An optional string argument which specifies the type of data
being attached. The value must be a valid MIME content type. If
this parameter is omitted or passed as an empty string, then the
buffer will be examined to determine what kind of data it contains.
If there is only text characters, then the content type will be
specified as "text/plain". If the buffer contains binary
data, then the content type will be specified as
"application/octet-stream", which is appropriate for any
type of data.
- Options
- An optional integer value which specifies one or more options.
This parameter is constructed by using a bitwise operator with any
of the following values:
Value |
Description |
mailAttachDefault |
The data encoding is based on the content type. Text data
is not encoded, and binary data is encoded using the standard
base64 encoding algorithm. If this argument is omitted, this is
the default value used. |
mailAttachBase64 |
The data is always encoded using the standard base64
algorithm, even if the buffer only contains printable text
characters. |
mailAttachUucode |
The data is always encoded using the uuencode algorithm,
even if the buffer only contains printable text
characters. |
mailAttachQuoted |
The data is always encoded using the quoted-printable
algorithm. This encoding should only be used if the data
contains 8-bit text characters. |
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 AttachData method attaches the contents of a string or
byte buffer to the current message.
Example
The following example demonstrates how to use the
AttachData method in Visual Basic:
Dim hFile As Integer
Dim lpBuffer() As Byte
Dim cbBuffer As Long
' Open a file for binary access and read it into a
' byte array that will be attached to the message
hFile = FreeFile()
Open strDataFile For Binary As hFile
cbBuffer = LOF(hFile)
ReDim lpBuffer(cbBuffer)
Get hFile, , lpBuffer
Close hFile
' Compose a new message and then attach the contents
' of the buffer
InternetMail1.ComposeMessage strFrom, _
strTo, _
strCc, _
strSubject, _
strMessage
InternetMail1.AttachData lpBuffer, cbBuffer, strDataFile
See Also
Attachment Property,
AttachFile Method,
ExtractFile Method
|
|