好吧,我已经完成了我的功课,甚至查看了这个网站上的几个示例,但无济于事。我的程序旨在发送表格上填写的数据,并将其发送到电子邮件。我的代码的其余部分没有显示任何错误,除了 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();
}