请教实现内网发送邮件功能
公司的领料系统填写申请领料单后,
希望系统能自动发送一份邮件给上级审核,
(公司的网络与外网是断开的,但公司内部有内部的邮件系统)
请教如何实现内网邮件发送
我在网上找了一段代码是发送外网的,已經测试发送邮件成功,现在我要改成发送内网地址的邮件,请教如何修改,谢谢!
发送外网的代码如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
format.Items.Add(new ListItem("文本", "0"));
format.Items.Add(new ListItem("HTML", "1"));
format.Items[0].Selected = true;
fromMail.Text = "要用內網的地址"; //发送方邮件
fromMail.Enabled = false;
}
}
private bool SendMail(string fromMail, string toMail, string ccMail, string bccMail, string subject, string body, string sendMode)
{
try
{
MailMessage myMail = new MailMessage();
myMail.From = fromMail;
myMail.To = fromMail;
myMail.Cc = ccMail;
myMail.Bcc = bccMail;
myMail.Subject = subject;
myMail.Body = body;
myMail.BodyFormat = sendMode == "0" ? MailFormat.Text : MailFormat.Html;
//附件
string ServerFileName = "";
if (this.upfile.PostedFile.ContentLength != 0)
{
string upFileName = this.upfile.PostedFile.FileName;
string[] strTemp = upFileName.Split('.');
string upFileExp = strTemp[strTemp.Length - 1].ToString();
ServerFileName = Server.MapPath(DateTime.Now.ToString("yyyyMMddhhmmss") + "." + upFileExp);
this.upfile.PostedFile.SaveAs(ServerFileName);
myMail.Attachments.Add(new MailAttachment(ServerFileName));
}
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "JACKY"); //发送方邮件帐户
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "think614"); //发送方邮件密码
SmtpMail.SmtpServer = "smtp." + fromMail.Substring(fromMail.IndexOf("@") + 1);
SmtpMail.Send(myMail);
return true;
}
catch
{
return false;
}
}
protected void send_Click(object obj, EventArgs e)
{
bool flag = SendMail(fromMail.Text, toMail.Text, ccMail.Text, bccMail.Text, subject.Text, body.Text, format.SelectedValue);
if (flag == true)
{
Response.Write("<script>alert('发送成功!');</script>");
}
else
{
Response.Write("<script>alert('发送失败!');</script>");
}
}
------解决方案--------------------别这么复杂,用论坛内部短消息的功能就可以实现。
------解决方案--------------------用内部消息就行啦,没必要用到邮件吧
------解决方案--------------------