how to send email with attachment from local machine
using System.Net.Mail;
public partial class SUPER_mail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button4_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("your gmail id");
msg.To.Add(TextBox2.Text);
msg.Subject = TextBox3.Text;
msg.Body = TextBox4.Text;
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs("C:\\Program Files (x86)\\Common Files\\microsoft shared\\DevServer\\10.0\\" + FileUpload1.FileName);
Label3.Text = FileUpload1.FileName;
msg.Attachments.Add(new Attachment(Label3.Text));
}
SmtpClient smt = new SmtpClient();
smt.Send(msg);
Label2.Text = "mail sucessfully transfer";
}
}
//inside the web.config file
<system.net >
<mailSettings >
<smtp >
<network host ="smtp.gmail.com" password ="your gmail password" userName ="your gmail id"/>
</smtp>
</mailSettings>
</system.net>
Revision number 1, Thursday, November 10, 2011 10:25:10 PM by tarunsaini
You must Login to comment.
Revision #5
Tue, Nov 3, 2009 7:16 PM
by
|
Sending Email in Asp.net
Sending email is very common in Asp.net application. In most of asp.net applications I was asked to send email to client or admin etc. Meanwhile, almost always I was asked to change content of email many times. Like change a sentence, put space between sentences
|
Revision #6
Mon, Nov 30, 2009 6:05 PM
by
|
Custom Error messages using Global.asax and Membership model
Scenario: Using ASP.NET membership model to display custom error messages to general users of a website. Send an email to a Webmaster with all the details of such an exception. Also in development environment only detailed exceptions are to be displayed and
|
Revision #4
Fri, Jul 4, 2008 10:48 AM
by
|
RegularExpressionValidator
The RegularExpressionValidator control confirms that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses
|
Revision #3
Fri, Oct 21, 2011 7:44 PM
by
|
Send email with smtp authentication using ASP.NET 3.5
Following Codes demonstrates how to send an email with SMTP Authentication using ASP.NET 3.5 using System.Net.Mail MailMessage msgMail = new MailMessage(); MailMessage myMessage = new MailMessage(); myMessage.From = new MailAddress("sender's email"
|