how do I create an email with VB? when we click the button, type in all the data we sent to the email address we are headed

objRecipient.Type = mapiTo
objRecipient.Resolve


there is an error in mapito

Add reference : Microsoft CDO For Windows 2000 Library
5 textboxes, 1 button
Try This :

Private Sub Command1_Click()
    
    On Error GoTo ErrHandler
    
    Dim oConfig As New CDO.Configuration
    Dim oMsg As New CDO.Message
    
    Label1.Caption = ""
    
    With oConfig.Fields
       .Item(cdoSendUsingMethod) = cdoSendUsingPort
       .Item(cdoSMTPServerPort) = 465
       .Item(cdoSMTPServer) = "smtp.mail.yahoo.com"
       .Item(cdoSMTPAuthenticate) = cdoBasic
       .Item(cdoSendUserName) = txtSender.Text
       .Item(cdoSendPassword) = txtPassword.Text
       .Item(cdoSendEmailAddress) = txtSender.Text
       .Item(cdoSMTPUseSSL) = 1
       .Update
    End With
    
    With oMsg
       .Configuration = oConfig
       .Subject = txtSubject.Text
       .To = txtAddress.Text
       .From = txtSender.Text
       .HTMLBody = txtMessage.Text
       .Send
    End With
    
    Set oMsg = Nothing
    Set oConfig = Nothing
    
    Label1.Caption = "Email Sent"
    Exit Sub

ErrHandler:

    MsgBox Err.Description, vbCritical, "Error"

End Sub

Add reference : Microsoft CDO For Windows 2000 Library
5 textboxes, 1 button
Try This :

Private Sub Command1_Click()
    
    On Error GoTo ErrHandler
    
    Dim oConfig As New CDO.Configuration
    Dim oMsg As New CDO.Message
    
    Label1.Caption = ""
    
    With oConfig.Fields
       .Item(cdoSendUsingMethod) = cdoSendUsingPort
       .Item(cdoSMTPServerPort) = 465
       .Item(cdoSMTPServer) = "smtp.mail.yahoo.com"
       .Item(cdoSMTPAuthenticate) = cdoBasic
       .Item(cdoSendUserName) = txtSender.Text
       .Item(cdoSendPassword) = txtPassword.Text
       .Item(cdoSendEmailAddress) = txtSender.Text
       .Item(cdoSMTPUseSSL) = 1
       .Update
    End With
    
    With oMsg
       .Configuration = oConfig
       .Subject = txtSubject.Text
       .To = txtAddress.Text
       .From = txtSender.Text
       .HTMLBody = txtMessage.Text
       .Send
    End With
    
    Set oMsg = Nothing
    Set oConfig = Nothing
    
    Label1.Caption = "Email Sent"
    Exit Sub

ErrHandler:

    MsgBox Err.Description, vbCritical, "Error"

End Sub

when I run this program there is a mistake that gave the role like this. Could not save this message to be sent to the smtp.server. The transport error code was 0x80040217 The server response

thank you for your help Mr Jx-Man. everything looks so easy for your help

This question has already been answered. Start a new discussion instead.