Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }
- protected void btnSend_Click(object sender, EventArgs e)
- {
- MailMessage mm = new MailMessage("sender@gmail.com", "receiver@gmail.com");
- mm.Subject = txtSubject.Text;
- mm.Body = "Name: " + txtName.Text + "<br /><br />Email: " + txtEmail.Text + "<br />" + txtBody.Text;
- if (FileUpload1.HasFile)
- {
- string FileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
- mm.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileName));
- }
- mm.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.EnableSsl = true;
- System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
- NetworkCred.UserName = "heba@e-tarabut.com";
- NetworkCred.Password = "hebhebheb91";
- smtp.UseDefaultCredentials = true;
- smtp.Credentials = NetworkCred;
- smtp.Port = 587;
- smtp.Send(mm);
- lblMessage.Text = "Email Sent SucessFully.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement