开发者

How to send this form using SMTP and VB.NET?

开发者 https://www.devze.com 2023-02-05 01:24 出处:网络
My code was .... But it only send one field value to email .... I want multiple values to be send as it is in mail ... like ..

How to send this form using SMTP and VB.NET?

My code was .... But it only send one field value to email .... I want multiple values to be send as it is in mail ... like ..

Category :
Your name :
Email ID
Mobile no. etc..

All form values will be transferred to mail ID ...

Imports System.Net.Mail
    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
        Try
            Dim SmtpServer As New SmtpClient()
            Dim mail As New MailMessage()
            SmtpServer.Credentials = New Net.NetworkCredential("bus@volvobusesindia.com", "pink&777")
            SmtpServer.Port = 25
            SmtpServer.Host = "mail.volvobusesindia.com"
            mail = New MailMessage()
            mail.From = New MailAddress(TextBox12.Text)
            mail.To.Add("bus@volvobusesindia.com")
            mail.Subject = "New Bus Booking Query"
            mail.Body = "Category :" & " " & DropDownList3.SelectedItem.Text
            SmtpServer.Send(mail)
            MsgBox("mail send")
        Catch ex As Exception
            MsgBox(ex.ToString)
    开发者_如何学Go    End Try

    End Sub


In this line:

        mail.Body = "Category:" & " " & DropDownList3.SelectedItem.Text 

You send only the category, you need to add the other information to the Body.

I do not know the names of the fields on your form but you need to change it to something like this:

        mail.Body = "Category:" & " " & DropDownList3.SelectedItem.Text + "<br>" + "Name: " + txtName.Text
0

精彩评论

暂无评论...
验证码 换一张
取 消