gmail アカウントを介してメールを送信していますが、プログラムを実行すると、smtp 例外が発生
しました。 "}"
**.aspx code:**
your Email assdress:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label3" runat="server" Text="Labe3"></asp:Label>
<asp:button ID="Button1" runat="server" text="Button" OnClick="button1_click" />
**.aspx.cs**
public void button1_click(object sender, EventArgs e)
{
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(TextBox1.Text);
// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "smtp.gmail.com";
smtpClient.EnableSsl = true;
//Default port will be 25
smtpClient.Port = 25;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("irfan.dilwaley@gmail.com");
message.Subject = "Feedback";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
// You can specify Address directly as string
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;
// Message body content
// Send SMTP mail
smtpClient.Send(message);
Label3.Text = "Email successfully sent.";
}
}