次の関数を使用します。
Public Sub SendMail(ByVal SendFrom As String, ByVal SendTo As String, ByVal Subject As String, ByVal Body As String)
Dim client As New SmtpClient
Dim message As New MailMessage
message.Body = Body
message.Subject = Subject
message.From = New MailAddress(SendFrom)
message.To.Add(New MailAddress(SendTo))
client.Port = "25"
client.Host = "smtp.myserver.com"
client.Send(message)
End Sub
私はそれを
Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
Dim iandamsb As New StringBuilder
iandamsb.AppendLine("Please make the following changes:")
iandamsb.AppendLine("")
iandamsb.AppendLine("Current name:" & txtCurrentName.Text)
iandamsb.AppendLine("New name:" & txtNewName.Text)
iandamsb.AppendLine("New username:" & txtNewUsername.Text)
iandamsb.AppendLine("Applications:" & txtOtherApplications.Text)
Dim iandambody As String = iandamsb.ToString
SendMail(txtRequesterEmail.Text, "ayockel@mydomain.com", "Name Change Request - " & txtCurrentName.Text, iandambody)
End Sub
正常に動作しますが、1通ではなく2通のメールを送信しています。なぜ重複を送信しているのか誰かが理解できますか?