namespace WindowsFormsAppEmailClient
{
public partial class Form1 : Form
{
MailMessage MyMsg = new MailMessage();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnSend_Click(object sender, EventArgs e)
{
SmtpClient MyServer = new SmtpClient("smtp.gmail.com", 587);
//defining global MyMsg so we use it in attachment button
// MailMessage MyMsg = new MailMessage();
MyMsg.From = new MailAddress( "[email protected]");
MyMsg.To.Add(tbTo.Text);
if (tbcc.Text != "")
{
MyMsg.CC.Add(tbcc.Text);
}
MyMsg.Subject = tbSub.Text;
//message = body
MyMsg.Body = tbMsg.Text;
MyServer.EnableSsl = true;
//Credentials used for defining User Name + Password
MyServer.Credentials = new System.Net.NetworkCredential("[email protected]", "03456016286");
MyServer.Send(MyMsg);
}
private void btnAtt_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
Attachment myFile = new Attachment(openFileDialog1.FileName);
MyMsg.Attachments.Add(myFile);
}
}
}
問題是:我想在電子郵件發送成功時顯示成功消息框。請幫忙顯示消息框
請告訴我你沒」不要在代碼中發佈真實的憑據。 – itsme86
親愛的我只需要點擊發送電子郵件「成功」的「顯示消息」 –
是的,它的真實性和備份郵件地址不是太難以解決,所以你可能想要現在更改密碼;) – SwDevMan81