标题:[求助]关于邮件发送的问题
只看楼主
lianxin19
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2006-7-8
 问题点数:0 回复次数:0 
[求助]关于邮件发送的问题

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Web.Mail;

namespace HrSalary
{
public partial class EmailSender : Form
{
public EmailSender()
{
InitializeComponent();
}
private string sender_check()
{
string error = "";

if (this.textBox4.Text =="" || this.textBox4.Text.Trim().Equals(""))
{
error = "发件人邮件不能为空!\n 请重新更新\n";
return error;
}
if ((this.textBox4.Text.IndexOf("@") == -1) ||( this.textBox4.Text.IndexOf(".") == -1))
{
error += "发件人油箱格式不正确!\n  请重新更新\n";
return error;
}
return error;

}
private void button2_Click(object sender, EventArgs e)
{
string error = "";
error = sender_check();
if (error != "")
{
MessageBox.Show(error);
return;
}
else
{
MailMessage mailObj = new MailMessage();
mailObj.From = this.textBox4.Text; //谁发的
mailObj.To = this.textBox1.Text; //发给谁
mailObj.Subject = this.textBox2.Text;//邮件主题
mailObj.Body = this.richTextBox1.Text; //邮件内容
mailObj.BodyFormat = MailFormat.Html;//邮件形式
mailObj.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");//gb18030
mailObj.Priority = MailPriority.High;
//以下完成验证
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/senda_username", this.textBox6.Text); //set your a_username here
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.textBox5.Text); //set your password here
SmtpMail.SmtpServer = this.textBox3.Text;
SmtpMail.Send(mailObj);

MessageBox.Show("发送成功!~");
}

}

private void button3_Click(object sender, EventArgs e)
{

}
}
}
邮件无法发送到 SMTP 服务器。传输错误代码为 0x80040217。服务器响应为 not available
这是什么错误?

搜索更多相关主题的帖子: using System 邮件 string public 
2007-05-12 09:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-138718-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.657343 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved