Hi all
I can't solve this problem: Value of type 'String' cannot be converted to 'MailMessage'.
Here is my code:
When I compile, here is my problem : SMTP.Send(emails)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




Reply With Quote
