|
|
Title | Use CDO to send email in Visual Basic 6 |
Description | This example shows how to use CDO to send email in Visual Basic 6. |
Keywords | CDO, email, send email |
Categories | Office |
|
|
First add a reference to the Microsoft CDO library.
When the user fills in the fields and clicks the Send button, the program creates a CDO Message object, fills in its fields, and calls its Send method.
|
|
' Note: Add a reference to the Microsoft CDO library.
Private Sub cmdSend_Click()
Dim cdo_msg As Object
Set cdo_msg = CreateObject("CDO.Message")
cdo_msg.Subject = txtSubject.Text
cdo_msg.From = txtFrom.Text
If Len(txtTo.Text) > 0 Then cdo_msg.To = txtTo.Text
If Len(txtCc.Text) > 0 Then cdo_msg.Cc = txtCc.Text
If Len(txtBcc.Text) > 0 Then cdo_msg.Bcc = txtBcc.Text
If Len(txtAttachment.Text) > 0 Then
cdo_msg.AddAttachment txtAttachment.Text
End If
cdo_msg.TextBody = txtBody.Text
cdo_msg.Send
Set cdo_msg = Nothing
End Sub
|
|
|
|
|
|