<a href="#" onclick="window.open('new.aspx','New_Win','Height=400px,Width=400px' )''>view </a>

Programming is fun and interesting. As you all know, sometime we programmers stucks in the middle way of coding without getting a solution. Blogs like this will help us to find a path to solve our problems. The contents of this blog are the solutions that I found by myself and from other sources. Sharing such solutions is also interesting. Thank you!
Sunday, August 18, 2013
Email with attachment
using System;
02.using System.Data;
03.using System.Configuration;
04.using System.Web;
05.using System.Web.Security;
06.using System.Web.UI;
07.using System.Web.UI.WebControls;
08.using System.Web.UI.WebControls.WebParts;
09.using System.Web.UI.HtmlControls;
10.using System.Net.Mail;
11.
12.public partial class _Default : System.Web.UI.Page
13.{
14. protected void Page_Load(object sender, EventArgs e)
15. {
16.
17. }
18. protected void btnSend_Click(object sender, EventArgs e)
19. {
20. MailMessage mail = new MailMessage();
21. mail.To.Add(txtTo.Text);
22. //mail.To.Add("amit_jain_online@yahoo.com");
23. mail.From = new MailAddress(txtFrom.Text);
24. mail.Subject = txtSubject.Text;
25. mail.Body = txtMessage.Text;
26. mail.IsBodyHtml = true;
27.
28. //Attach file using FileUpload Control and put the file in memory stream
29. if (FileUpload1.HasFile)
30. {
31. mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
32. }
33. SmtpClient smtp = new SmtpClient();
34. smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
35. smtp.Credentials = new System.Net.NetworkCredential
36. ("YourGmailID@gmail.com", "YourGmailPassword");
37. //Or your Smtp Email ID and Password
38. smtp.EnableSsl = true;
39. smtp.Send(mail);
40.
41. }
02.using System.Data;
03.using System.Configuration;
04.using System.Web;
05.using System.Web.Security;
06.using System.Web.UI;
07.using System.Web.UI.WebControls;
08.using System.Web.UI.WebControls.WebParts;
09.using System.Web.UI.HtmlControls;
10.using System.Net.Mail;
11.
12.public partial class _Default : System.Web.UI.Page
13.{
14. protected void Page_Load(object sender, EventArgs e)
15. {
16.
17. }
18. protected void btnSend_Click(object sender, EventArgs e)
19. {
20. MailMessage mail = new MailMessage();
21. mail.To.Add(txtTo.Text);
22. //mail.To.Add("amit_jain_online@yahoo.com");
23. mail.From = new MailAddress(txtFrom.Text);
24. mail.Subject = txtSubject.Text;
25. mail.Body = txtMessage.Text;
26. mail.IsBodyHtml = true;
27.
28. //Attach file using FileUpload Control and put the file in memory stream
29. if (FileUpload1.HasFile)
30. {
31. mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
32. }
33. SmtpClient smtp = new SmtpClient();
34. smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
35. smtp.Credentials = new System.Net.NetworkCredential
36. ("YourGmailID@gmail.com", "YourGmailPassword");
37. //Or your Smtp Email ID and Password
38. smtp.EnableSsl = true;
39. smtp.Send(mail);
40.
41. }
Send Email using Gmail - asp.net C#
MailMessage mail = new MailMessage();
mail.To.Add("syam229280@gmail.com");
mail.To.Add("deepu04852@gmail.com");
mail.From = new MailAddress("syam229280@gmail.com");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail" +
"using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential
("syam229280@gmail.com", "password");
smtp.EnableSsl = true;
smtp.Send(mail);
mail.To.Add("syam229280@gmail.com");
mail.To.Add("deepu04852@gmail.com");
mail.From = new MailAddress("syam229280@gmail.com");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail" +
"using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential
("syam229280@gmail.com", "password");
smtp.EnableSsl = true;
smtp.Send(mail);
Code for label text with new lines - asp.net C#
label1.Text=dt.Rows[0][""text"].ToString().Replace(Enviornment.NewLine,"<br>");
Subscribe to:
Posts (Atom)