さて、私は宿題をやりました。このウェブサイトでいくつかの例を見ましたが、役に立ちませんでした. 私のプログラムは、フォームに記入されたデータを送信し、それを電子メールで送信することを目的としています。私のコードの残りの部分は、SmptMailMessage を除いてエラーを表示しません。これが私のコードです:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
namespace FPSArrestReport
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn1_Click(object sender, EventArgs e)
{
SmtpClient SmptMailMessage = new SmtpClient();
SmptMailMessage mail = new SmtpMailMessage("smtp.gmail.com", 25); // error on this line
\\on the SmptMailmessage
//set the to address to the primary email
mail.To.Add("xxx@abc.com");
//set the message type and subject and body
mail.IsHtmlMessage = true;
mail.Subject = "";
mail.Body = "Hello world!";
//send the email
mail.Send();
}