อยากให้ลองยกตัวอย่างการ Config Server และการแทนค่าตัวแปรให้ดูหน่อย
ผมใส่ ? ไว้หลังบรรทัดที่ผมไม่แน่ใจว่าต้องเอาตัวแปรอะไรจากไหนมาใส่
Code
Imports System.Net.Mail
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Set the caption bar text of the form.
Me.Text = "tutorialspoint.com"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("[email protected]", "password") ?
Smtp_Server.Port = 587 ?
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com" ?
e_mail = New MailMessage()
e_mail.From = New MailAddress() ?
e_mail.To.Add("[email protected]")
e_mail.Subject = "Email Sending"
e_mail.IsBodyHtml = False
e_mail.Body = "Test Email"
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString)
End Try
End Sub