RT 我用的winform程序,把本地的图片发送到邮箱!163 qq邮箱都可以!坐等高手
解决方案 »
- 请高人指点如何将字符串转换成数值
- 我是一个菜鸟,怎么用Xml的流式操作添加和修改Xml中的数据,不用Document方法,只用XmlWriter()和XmlReader()
- 用C#上传图片并生成缩略图时,缩略图特模糊,如何解决?
- SmtpClient的问题
- .net 2.0 treeview控件单击事件的问题
- 用socket 怎么判断用户是否连接到服务器?
- 循环执行sql语句,最后一起提交,出现多行的时候总是在等待状态,一行就没有问题
- 查询问题?
- pdg文件怎么打开
- 我替qifang问的安装问题,请有安装经验的兄弟们给这位兄弟帮帮忙
- 预处理指令,Release版本不行呢
- udp 异步发送 出错!
{
string To = this.textBox1.Text;//发送到
string From = this.textBox2.Text;//发送邮箱
string password = this.MaskedtextBox1.Text;//发送邮箱密码
string name = this.textBox3.Text;
if (To != "" & From != "")
{
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = false;
smtp.Host = "smtp.163.com";//格式:smtp.163.com
smtp.Port = 25;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new NetworkCredential(From, password);
MailMessage Message = new MailMessage();
// Message.BodyEncoding = System.Text.Encoding.UTF8;
Message.Priority = MailPriority.High;
Message.From = new MailAddress(From, name, Encoding.GetEncoding(936));
Message.ReplyTo = new MailAddress(From, "我的接收邮箱", Encoding.GetEncoding(936));
Message.To.Add(ToAd);
Message.Subject = textBox4.Text; //邮件标题
Message.SubjectEncoding = Encoding.GetEncoding(936);
Message.IsBodyHtml = true;
Message.BodyEncoding = Encoding.GetEncoding(936);
Message.Body = textBox5.Text;//内容
if (textBox6.Text != "")
{
Attachment att = new Attachment(@textBox6.Text);
Message.Attachments.Add(att);//加附件
} try
{
if (textBox6.Text != "")
{ EmailWithProgress();
}
smtp.Send(Message); //发送邮件,如果不返回异常, 则大功告成了。 MessageBox.Show("Email 已发送完成!", "系统V2.01");
}
catch (Exception ex)
{
MessageBox.Show("发送失败!" + ex.ToString(), "系统V2.01");
} }
}
public static int filelen = 0;
private void EmailWithProgress()
{
string filepath = textBox6.Text;
if (!File.Exists(filepath))
{
MessageBox.Show(filepath + "文件不存在", "系统V2.01");
return;
}
else
{ FileInfo fi1elens = new FileInfo(filepath);
int filelen = Convert.ToInt32(fi1elens.Length); progressBar1.Visible = true;//进度条
progressBar1.Minimum = 1;
progressBar1.Maximum = filelen;
progressBar1.Value = 1;
progressBar1.Step = 1;
for (int x = 1; x <= filelen; x++)
{
if (filelen > 0)
{
progressBar1.PerformStep();
} } }
}
private void button2_Click(object sender, EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
textBox6.Text = openFileDialog1.FileName;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} }
为什么会弹出
A recipient must be specified.
接收者必须被指定。
这个错误呢~?