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

Recommended Answers

All 12 Replies

what else can I if I do not have VB CDO 1:21 Library?

I do not have VB CDO 1:21 Library?

What do you mean by that ?

Try using MAPI controls.

objRecipient.Type = mapiTo
objRecipient.Resolve


there is an error in mapito

post your complete code .

read more here.

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

See this attachment.

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

You're welcome.
Happy Coding :)

Jx Man is already Genius 'dud'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.