Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse CDO to send email in Visual Basic 6
DescriptionThis example shows how to use CDO to send email in Visual Basic 6.
KeywordsCDO, email, send email
CategoriesOffice
 
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
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated