小技巧

如此一般的下载文件吧

string filepath="";
filepath=Server.MapPath("ImgeTemp")+"//temp.jpg";
System.IO.FileInfo myFile = new System.IO.FileInfo(filepath);
filename=this.Request["ImgePath"];
filename=filename.Substring(filename.Length-3,3);
if (filename=="jpg")
{
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(myFile.Name));
}
else
{
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("temp.tif"));
}
Response.AddHeader("Content-Length", myFile.Length.ToString());
this.Response.ContentType="application/octet-stream";
Response.WriteFile(myFile.FullName);
Response.flush();
this.Response.End();
 

 

//如此发邮件

这个是最好我成功运行的结果,大家看看,谢谢大家了:
      
        //创建MailMessage对象
        MailMessage mailMsg = new MailMessage();
        //设置收件人的邮件地址
        mailMsg.To = "evien007@yahoo.com.cn";

        //设置发送者的邮件地址
        mailMsg.From = "kevinxwww@163.com";

        //设置邮件主题
        mailMsg.Subject = "测试";

        //设置邮件内容
        mailMsg.Body = "你的用户名是866666密码是533332";


        //设置为需要用户验证
        mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        //设置验证用户名(邮箱的用户名)
        mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "kevinxwww");
        //设置验证密码(邮箱的密码)
        mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
        //设置发送邮件服务器


        SmtpMail.SmtpServer = "smtp.163.com";
        //发送邮件
        SmtpMail.Send(mailMsg);
        msg.Text = "邮件发送成功";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值