Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..

C#
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!
Posted
Comments
Herman<T>.Instance 2-Aug-11 5:11am    
what is your exact problem. Based on information and code I cannot reproduce this.
You want to add datetime to what?

1 solution

Big deal?

Change your code like below(Just need to concatenate the datetime to filename)
C#
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");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900