Click here to Skip to main content
15,904,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

C#
if (fileAttachement.PostedFile != null)
{
    // Get a reference to PostedFile object

    HttpPostedFile ulFile = fileAttachement.PostedFile;
    // Get size of the file

    int nFileLen = ulFile.ContentLength;
    // Make sure the size of the file is > 0

    if (nFileLen > 0)
    {
        // Get the file name

        FileName = Path.GetFileName(fileAttachement.PostedFile.FileName);
        // Preced the file name with "attachments/" so

        // the file is saved to our attachments directory

        FileName = "AttachedFiles/" + FileName;
        // Save the file on the server

        fileAttachement.PostedFile.SaveAs(Server.MapPath(FileName));
        // Create the email attachment with the uploaded file

        System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath(FileName));
        // Attach the newly created email attachment

        obj.Attachments.Add(attach);
        // Store filename so we can delete it later

        //attach1 = strFileName;
    }
}


this is my coding for sending email with attachment..how to add more attachment in this..how to put this in array..anybody know reply

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 26-Aug-11 23:11pm
v2

1 solution

If you look here: Sending an Email in C# with or without attachments: generic routine.[^] you will find a generic routine that includes multiple attachments. It's pretty obvious from that!
 
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