hii
you will try this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
//using System.Web.Mail;
using System.Net;
using System.Configuration;
public partial class ASPX_eMails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MailMessage msg = new MailMessage(txtfrommailid.Text,txttoemailid.Text,txtsubject.Text.ToString(),txtbody.Text.ToString());
msg.IsBodyHtml = true;
//if (FileUpload1.HasFile)
//{ // msg.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
//} if (FileUpload1.HasFile)
{ msg.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
} NetworkCredential Nc = new NetworkCredential(txtfrommailid.Text, "@bangaru");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = Nc;
smtp.Send(msg);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Label1.Text = "Your mail is sent sucsessfull";
}}
Thanks & Regards
Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri
.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator