我正在尝试在 Visual Studio 2008 中为 Windows Phone 创建一个简单的电子邮件发送应用程序,所以请告诉我必须使用哪些类或方法。
我试过了,但没有用:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Configuration;
using System.Xml;
try
{
Application.DoEvents();
// setup mail message
MailMessage message = new MailMessage();
message.From = new MailAddress(textBox1.Text);
message.To.Add(new MailAddress(textBox2.Text));
message.Subject = textBox3.Text;
message.Body = textBox5.Text;
// setup mail client
SmtpClient mailClient = new SmtpClient("smtp.gmail.com");
mailClient.Credentials = new NetworkCredential(textBox1.Text, textBox4.Text);
mailClient.Send(message);
MessageBox.Show("Sent");
}
catch (Exception)
{
MessageBox.Show("Error");
}
我收到这些错误:
Error 1 The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'MailAddress' could not be found (are you missing a using directive or an assembly reference?)
Error 4 The type or namespace name 'MailAddress' could not be found (are you missing a using directive or an assembly reference?)
Error 5 The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
Error 6 The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
Error 7 The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
Error 8 The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)