Click here to Skip to main content
15,908,775 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hi,
can u tell me. i have try this code..

MailMessage myMess = new MailMessage("pradeep.mudiam@gmail.com","maddulapradeep@gmail.com");

//myMess.From = "info@achbiz.com";
myMess.Subject = "hi";
myMess.Body = "hghhh";

string Body = "jhgg";


AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");

string Fname = Path.GetFileName(FileUpload1.PostedFile.FileName);

string fServerDirPath = Server.MapPath("~/Upload//Document");

//Check Directory Exist or Not if Not Then Create New Directory

string fType = FileUpload1.PostedFile.ContentType;
Attachment objAttachment1 = new Attachment(FileUpload1.PostedFile.FileName);


int fSize = FileUpload1.PostedFile.ContentLength;

if (!Directory.Exists(fServerDirPath))
{
    Directory.CreateDirectory(fServerDirPath);
}

string fServerFileFullPath = fServerDirPath + Fname;

if (fType == "text/plain" || fType == "application/msword" || fType == "application/vnd.ms-excel" || fType == "application/vnd.ms-powerpoint")
{
    if (fSize <= 2097152) //Check Size for 2 MB
    {
        FileUpload1.SaveAs(fServerFileFullPath);

        Response.Write("File Successfully Uploaded");
    }
    else
    {
        Response.Write("Please Upload only Maximum 2 MB Size");
    }
}
else
{
    Response.Write("Please Upload only Txt/Doc/XLS/PPT File");
}
myMess.Attachments.Add(objAttachment1);

myMess.IsBodyHtml = true;

SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mySmtpClient.Host = "mail.payroll-taxes.info";
mySmtpClient.Port = 25;
mySmtpClient.Credentials = new NetworkCredential("support@payroll-taxes.info", "mnb1234");
mySmtpClient.Send(myMess);


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 13-Jun-11 3:01am
v2

Check Out This Link..

You May Get Solution..
ASP.NET email with multiple attachments

As Per Ur Code

Just Create More Attachment Object
And That One Also
myMess.Attachments.Add(objAttachment1);
myMess.Attachments.Add(objAttachment2);
 
Share this answer
 
v3
Try specifying the ContentType[^] - at the moment you are attaching the filename as a string, rather than the file itself. You may also need to use the Server.MapPath method as well in order to locate the file properly.
 
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