X
xddouble
Unregistered / Unconfirmed
GUEST, unregistred user!
asp .net附件发送问题:发送桌面文件出错,发送其他地方文件无错,请解答,本人用vs.net2003.
private void Btn_Send_Click(object sender, System.EventArgs e)
{
int returnint = 0;
returnint = Convert.ToInt32( FunClass.SendMail(Page,TBmailTo.Text.Trim(), TBmailSubject.Text, TBmailCC.Text,Ftb_mailBody.Text ,upFile.PostedFile.FileName));
if(returnint == 0)
{
FunClass.ShowMessage(Page,"邮件发送失败!"
}
else
{
FunClass.ShowMessage(Page,"邮件已发送到"+TBmailTo.Text);
}
}
public int SendMail(Page pPage,string pToMail,string pSubject,string pCC,string pBody,string pUpfile)
{
try
{
MailMessage mailObj = new MailMessage();
mailObj.From = "xddouble@126.com";
mailObj.To = pToMail;
mailObj.Cc = pCC;
mailObj.Subject = pSubject;
mailObj.Body = pBody;
mailObj.BodyFormat = MailFormat.Text;
mailObj.Priority = MailPriority.High;
if(pUpfile.ToString() != String.Empty ||pUpfile.ToString() !=""
{
mailObj.Attachments.Add(new MailAttachment(pUpfile));
}
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthen
ticate", "1"
//basic authen
tication
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxxxx"
//set your username here
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxxx"
//set your password here
SmtpMail.SmtpServer = "smtp.126.com";
SmtpMail.Send(mailObj);
return 1;
}
catch
{
return 0;
}
}
private void Btn_Send_Click(object sender, System.EventArgs e)
{
int returnint = 0;
returnint = Convert.ToInt32( FunClass.SendMail(Page,TBmailTo.Text.Trim(), TBmailSubject.Text, TBmailCC.Text,Ftb_mailBody.Text ,upFile.PostedFile.FileName));
if(returnint == 0)
{
FunClass.ShowMessage(Page,"邮件发送失败!"
}
else
{
FunClass.ShowMessage(Page,"邮件已发送到"+TBmailTo.Text);
}
}
public int SendMail(Page pPage,string pToMail,string pSubject,string pCC,string pBody,string pUpfile)
{
try
{
MailMessage mailObj = new MailMessage();
mailObj.From = "xddouble@126.com";
mailObj.To = pToMail;
mailObj.Cc = pCC;
mailObj.Subject = pSubject;
mailObj.Body = pBody;
mailObj.BodyFormat = MailFormat.Text;
mailObj.Priority = MailPriority.High;
if(pUpfile.ToString() != String.Empty ||pUpfile.ToString() !=""
{
mailObj.Attachments.Add(new MailAttachment(pUpfile));
}
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthen
ticate", "1"
//basic authen
tication
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxxxx"
//set your username here
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxxx"
//set your password here
SmtpMail.SmtpServer = "smtp.126.com";
SmtpMail.Send(mailObj);
return 1;
}
catch
{
return 0;
}
}