object.ComposeMessage( From, To [,
Cc] [, Bcc] [, Subject] [, Msgtext] [,
Msghtml] [, Charset] [, Enctype] )
The ComposeMessage method syntax has the following
parts:
| Part |
Description |
| object
|
An object expression that
evaluates to an InternetMail object. |
| from
|
A string which specifies the
sender address. |
| to
|
A string which specifies one or
more recipient addresses. |
| cc
|
A string which specifies one or
more recipient addresses. |
| bcc
|
A string which specifies one or
more recipient addresses. |
| subject
|
A string which specifies the
subject of the message. |
| msgtext
|
A string which specifies the text
of the message. |
| msghtml
|
A string which specifies optional
HTML formatted text. |
| charset
|
An integer value which specifies
the message character set. |
| enctype
|
An integer value which specifies
the message encoding type. |
The ComposeMessage method creates a new mail message, or
replaces the current message if one already exists.
The From argument is required and specifies the sender's
e-mail address. Only a single address should be specified. After
the message has been composed, the From property will be
updated with this value.
The To argument is required and specifies one or more
recipient e-mail addresses. Multiple e-mail addresses may be
specified by separating them with commas. After the message has
been composed, the To property will be updated with this
value.
The Cc argument is optional and specifies one or more
additional recipient addresses that will receive a copy of the
message. If this argument is not specified, then no Cc header field
will be created for this message. After the message has been
composed, the Cc property will be updated with this
value.
The Bcc argument is optional and specifies one or more
additional recipient addresses that will receive a copy of the
message. Unlike the cc argument, these recipients will not
be included in the header of the message. If this argument is not
specified, then no blind carbon copies of the message will be sent.
After the message has been composed, the Bcc property will
be updated with this value.
The Subject argument is optional and specifies the
subject for the message. If the argument is not specified, then no
Subject header field will be created for this message. After the
message has been composed, the Subject property will be
updated with this value.
The Msgtext argument is optional and specifies the body
of the message. Each line of text contained in the string should be
terminated with a carriage-return/linefeed (CRLF) pair, which is
recognized as the end-of-line. If the argument is not specified,
then the message will have an empty body unless the Msghtml
argument has been specified.
The Msghtml argument is optional and specifies an
alternate HTML formatted message. If the Msgtext argument
has been specified, then a multipart message will be created with
both plain text and HTML text as the alternative. This allows mail
clients to select which message body they wish to display. If the
Msgtext argument is not specified or is an empty string,
then the message will only contain HTML. Although this is
supported, it is not recommended because older mail clients may be
unable to display the message correctly.
The Charset and Enctype arguments are optional and
specify the character set and encoding type for the message text.
The default is for the message to use the standard US-ASCII
character set and 7-bit encoding. Note that if an 8-bit character
set is selected, the default encoding type will be set to
quoted-printable.
This method will return a value of zero if the action was
successful. Otherwise, a non-zero error code is returned which
indicates the cause of the failure.
The following example composes a message and sends it to the
specified recipients:
Dim nError As Long
nError = InternetMail1.ComposeMessage(comboFrom.Text, _
editTo.Text, _
editCc.Text, _
editBcc.Text, _
editSubject.Text, _
editMessage.Text)
If nError <> 0 Then
MessageBox "Unable to compose message", vbExclamation
Exit Sub
End If
nError = InternetMail1.SendMessage()
If nError <> 0 Then
MsgBox "Unable to send message", vbExclamation
Exit Sub
End If