使用asp.net发送日期和附件 [英] sending date along with the attachments using asp.net

查看:103
本文介绍了使用asp.net发送日期和附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net通过电子邮件发送附件(PDF格式).但是我有一个要求,就像附件中的日期和时间"也应该被附加,即当前的日期和时间...我花了很多时间来做到这一点.但是我没有得到..

我的代码如下.

I am sending attachements(in pdf format) through email using asp.net. But I have requirement just like for the attachments "date and time" also should be attached i.e current date and time...I spent lot of time to do this .but i didn''t get it..

my code as follows..

try
        {

            rpt.ExportToPdf(Server.MapPath("reports\\") + ASPxDropDownEdit1.SelectedItem.Text +"-ConsumableReport.pdf");
        }
        catch (Exception ex)
        {
            //Response.Write(ex.Message);
        }

 Attachment attach = new Attachment(Server.MapPath("~\\reports") + "\\"  +ASPxDropDownEdit1.SelectedItem.Text + "-ConsumableReport.pdf");




有什么主意吗?
谢谢你!




any idea?
thank u!

推荐答案

大不了?

如下更改代码(只需将日期时间连接到文件名)
Big deal?

Change your code like below(Just need to concatenate the datetime to filename)
try
{
  string strCurrentDateTime = DateTime.Now.ToString("dd-MM-yyyy hh.mm");//Change Date time format based on your requirement 
  rpt.ExportToPdf(Server.MapPath("reports\\") + ASPxDropDownEdit1.SelectedItem.Text + "-ConsumableReport" + strCurrentDateTime + ".pdf");
}
catch (Exception ex)
{
 //Response.Write(ex.Message);
}

 Attachment attach = new Attachment(Server.MapPath("~\\reports") + "\\"  +ASPxDropDownEdit1.SelectedItem.Text + "-ConsumableReport" + strCurrentDateTime + ".pdf");


这篇关于使用asp.net发送日期和附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆