Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
some Difficulty with me ,

in my project
i have a class (send_mail.cs) and in class i define Sending mail By Admin.


how can i send mail with attached file from calling this class method in aspx.cs page...

please help me
Posted

 
Share this answer
 
Comments
mukesh mourya 24-Feb-14 2:19am    
sir this article is not work properly as i wont

here i have class (.cs page) which are used mor then one pages...

and i wont to call each pages according my declaration
Siva Hyderabad 24-Feb-14 2:25am    
Mukesh,You are posted the Requirement..if you get any exception or error ..we try to solve your problem...make try to your self..then come back..

see this google refered link once..

https://www.google.co.in/search?q=how+to+send+mail+with+attachment+in+asp.net+using+c%23&rlz=1C1CHMO_en-gbIN555IN555&oq=how+to+send+&aqs=chrome.0.69i59j69i57j69i60j0l2j69i60.4655j0j8&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8
mukesh mourya 24-Feb-14 2:42am    
sir,

my code is -

if (uploadfile.HasFile)
{
string Filename = uploadfile.PostedFile.FileName;
MailAttachment mailattechment=new MailAttachment(Filename,MailEncoding.Base64);
confirmationmail.Sendmailadmintouser(txtadress, txtmassege, txtSubject,mailattechment);

}
and in .Cs (Class) Page-



public static string Sendmailadmintouser(string emailidlist, string msgbody, string msgSubject,______________ mailattechment)
{
string res ="";




string mailid = string.Empty;
MailMessage msg = new MailMessage();
SmtpClient smtp = new SmtpClient();
mailid = emailidlist[j].ToString();
msg.From = new MailAddress("admin@gmail.com");
msg.To.Add(mailid);

msg.Subject = msgSubject.ToString();
msg.Body = msgbody.ToString();
msg.IsBodyHtml = true;
msg.Priority = MailPriority.Normal;
smtp.Credentials = new NetworkCredential("mukesh@gmail.com", "Password");
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;

smtp.Send(msg);
return res="Send";





//
How can Handel mailattechment File in class
Check with the author of the article.
 
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