TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vikas Ahlawat
NA
564
818k
sending email with win application?
May 28 2010 2:45 AM
I m sending email through window application with attachment when the mail successfully sent but after send mail i want to delete the attachment file.
But it give error
please help me
code is below
if (File.Exists(@"C:\abc.txt"))
{
//File.Delete(@"C:\abc.txt");
MailMessage mail = new MailMessage();
mail.To.Add("
[email protected]
");
mail.From = new MailAddress("
[email protected]
");
mail.Subject = "Email using Gmail";
Attachment attfile = new Attachment(@"C:\abc.txt");
mail.Attachments.Add(attfile);
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"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("
[email protected]
", "password");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
File.Delete(@"C:\abc.txt");// when i m deleting this file it give error that it is being used by another process
MessageBox.Show("email sent successfully");
}
Reply
Answers (
7
)
Seperating numbers from alphanumeric field using regex
Text Alignment problem in picturebox...