各位大哥大姐们救命啊

乞丐921 2011-03-30 10:02:02
都是用winfrom写的
问题1:发送邮件程序在xp系统下都能发送,在windows server 2003的系统不能发送
string fjrtxt = "aaa0323@163.com"; //发件者邮箱地址
string mmtxt = "qq123"; //发件者邮箱密码
string sjrtxt = "35435345@qq.com";//收件人收箱地址
string zttxt = "这是厕所";//主题

string nrtxt = "这是测试";//内容
string[] fasong = fjrtxt.Split('@');
string[] fs = fasong[1].Split('.');
//发送
SmtpClient client = new SmtpClient("smtp." + fs[0].ToString().Trim() + ".com"); //设置邮件协议
client.UseDefaultCredentials = false;//这一句得写前面
client.DeliveryMethod = SmtpDeliveryMethod.Network; //通过网络发送到Smtp服务器
client.Credentials = new NetworkCredential(fasong[0].ToString(), mmtxt); //通过用户名和密码 认证
MailMessage mmsg = new MailMessage(new MailAddress(fjrtxt), new MailAddress(sjrtxt)); //发件人和收件人的邮箱地址
mmsg.Subject = zttxt; //邮件主题
mmsg.SubjectEncoding = Encoding.UTF8; //主题编码
mmsg.Body = nrtxt; //邮件正文
mmsg.BodyEncoding = Encoding.UTF8; //正文编码
mmsg.IsBodyHtml = true; //设置为HTML格式
mmsg.Priority = MailPriority.High; //优先级
try
{
client.Send(mmsg);

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

问题2:同样上传图片到服务器,在xp系统下都能上传,在windows server 2003的系统不能上传
客户端代码:
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "图像文件 (*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG"; //上傳格式

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string fullpath = openFileDialog1.FileName;//文件路径
System.Net.WebClient myWebClient = new System.Net.WebClient();
myWebClient.UploadFile("http://localhost/up/Uploader.ashx", "POST", fullpath);


}

服务器代码:
<%@ WebHandler Language="C#" Class="Uploader" %>

using System;
using System.Web;
using System.IO;
public class Uploader : IHttpHandler {

public void ProcessRequest(HttpContext hc)
{
foreach (string fileKey in hc.Request.Files)
{
HttpPostedFile file = hc.Request.Files[fileKey];
file.SaveAs(Path.Combine(hc.Server.MapPath("."), file.FileName));

}
}
public bool IsReusable
{
get { return true; }
}


}


小弟觉得应该不是代码的问题,难道是windows server 2003做这两个功能需要什么组件???????????
...全文
58 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
blue999ice 2011-03-30
  • 打赏
  • 举报
回复
那SMTP服务是否开启了呢?
乞丐921 2011-03-30
  • 打赏
  • 举报
回复
SMTP 服务器组件已经安装了啊
threenewbee 2011-03-30
  • 打赏
  • 举报
回复
在Windows Server 2003的控制面板-管理服务器-角色,添加邮件服务器。
threenewbee 2011-03-30
  • 打赏
  • 举报
回复
是否安装 SMTP 服务器组件。

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧