这个是我写的文件上传和绑定mymsg的程序
System.Web.Mail.MailMessage mymsg=new MailMessage();
mymsg.From=txtfrom.Text;
mymsg.To=txtto.Text;
mymsg.Subject=txtsubject.Text;
mymsg.Body=txtbody.Text;
HttpPostedFile a=File1.PostedFile;
if(a.FileName!="")
{
char[] de={'\\'};
string[] Afilename=a.FileName.Split(de);
string strFilename=Afilename[Afilename.Length-1];
string strPath="c:"+"\\Temp\\"+strFilename;
a.SaveAs(strPath);
mymsg.Attachments.Add(new MailAttachment(strPath));
}这个我发送的程序: try
{
SmtpMail.SmtpServer="127.0.0.1";
SmtpMail.Send(mymsg);
show.Text="邮件发送成功";
}
catch(Exception)
{
show.Text="邮件发送失败";
}
我把这2个程序写在一个button击发事件里能发送成功但我尝试是将上传和发送分别弄到2个button的击发事件结果就发送不成功。请问在分开写的时候要注意哪些问题啊?
System.Web.Mail.MailMessage mymsg=new MailMessage();
mymsg.From=txtfrom.Text;
mymsg.To=txtto.Text;
mymsg.Subject=txtsubject.Text;
mymsg.Body=txtbody.Text;
HttpPostedFile a=File1.PostedFile;
if(a.FileName!="")
{
char[] de={'\\'};
string[] Afilename=a.FileName.Split(de);
string strFilename=Afilename[Afilename.Length-1];
string strPath="c:"+"\\Temp\\"+strFilename;
a.SaveAs(strPath);
mymsg.Attachments.Add(new MailAttachment(strPath));
}这个我发送的程序: try
{
SmtpMail.SmtpServer="127.0.0.1";
SmtpMail.Send(mymsg);
show.Text="邮件发送成功";
}
catch(Exception)
{
show.Text="邮件发送失败";
}
我把这2个程序写在一个button击发事件里能发送成功但我尝试是将上传和发送分别弄到2个button的击发事件结果就发送不成功。请问在分开写的时候要注意哪些问题啊?
解决方案 »
- 求救!我的vs2008怎么不支持ajax????
- 怎么少了一个?
- 我是初学者,问几个基本的问题。
- web服务器控件无法显示,但是页面aspx页面可以显示
- ASP.NET MVC2 部署到IIS7.0后,Javascript脚本无法执行。。。
- 同一站点,不同虚拟目录的应用程序,互相触发session_start ?
- 请教几个简单的正则表达式。////
- 教材中的一段话,不理解,请大家帮帮忙,谢谢!
- datagrid中使用图片按钮怎样触发事件???
- 如何在下拉菜单中加一个textBox。(webForm)
- 关于发送邮件的问题,请高手们帮忙,在线等。。。。急。。。。。。。。
- ------急,数据库连接问题,如何写相对路径???????
在第二个button里System.Web.Mail.MailMessage mymsg1=(System.Web.Mail.MailMessage)Session["mymsg"];