そこで、Visual C#アプリケーションを使用して自分自身にメールを送信したかったのですが、コードを実行しただけで(コードの最後にメッセージボックスを配置したため、これはわかっています)、何も送信されないようです。明らかな理由で、以下のメール情報を変更しました。
これが私が持っているものです:
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;
using System.Net;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string Host = "smtp.live.com";
Int16 Port = 587;
bool SSL = true;
string Username = "myemail@hotmail.com";
string Password = "mypassword";
// Mail options
string To = "myemail@hotmail.com";
string From = "email@hotmail.com";
string Subject = "This is a test";
string Body = "It works!";
MailMessage mm = new MailMessage(From, To, Subject, Body);
SmtpClient sc = new SmtpClient(Host, Port);
NetworkCredential netCred = new NetworkCredential(Username, Password);
sc.EnableSsl = SSL;
sc.UseDefaultCredentials = false;
sc.Credentials = netCred;
MessageBox.Show("Test");
}
}
}
*注意してください、これからエラーは発生しません。