Results 1 to 5 of 5

Thread: Value of type 'String' cannot be converted to 'MailMessage'.

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2016
    Posts
    5

    Post Value of type 'String' cannot be converted to 'MailMessage'.

    Hi all

    I can't solve this problem: Value of type 'String' cannot be converted to 'MailMessage'.

    Here is my code:
    Code:
     Sub send_mail()
    
            Dim email As New MailMessage()
            Dim strBody As String = ""
            Dim emails As String = ""
            Try
                Dim SMTP As New SmtpClient("mail.xxx.xo")
                SMTP.UseDefaultCredentials = True
                SMTP.Credentials = New System.Net.NetworkCredential("[email protected]", "xxxxxx")
                email.From = New MailAddress("[email protected]")
    
                If String.IsNullOrEmpty(emails) Then
                    emails = "[email protected]"
                Else
                    emails = TextBox4.Text
                End If
                emails = TextBox4.Text
                email.To.Add(emails)
                email.Subject = TextBox2.Text
                strBody = TextBox1.Text & TextBox5.Text & TextBox6.Text & TextBox7.Text & TextBox8.Text
                strBody = "bla bla bla" & vbCrLf
                strBody += "bla "
                strBody += TextBox1.Text & vbCrLf
                strBody += TextBox2.Text & vbCrLf
                strBody += TextBox5.Text & vbCrLf
                strBody += TextBox6.Text & vbCrLf
                strBody += TextBox7.Text & vbCrLf
                strBody += TextBox8.Text & vbCrLf
                email.Body = strBody
    
                SMTP.Send(emails)
                MsgBox("mail send")
            Catch ex As SmtpException
                MsgBox(ex.StatusCode & vbCrLf & ex.Message & ex.ToString, vbCritical, "SMTP Error!")
            End Try
    
        End Sub
    When I compile, here is my problem : SMTP.Send(emails)
    Last edited by si_the_geek; Aug 3rd, 2020 at 01:03 PM. Reason: added Code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width