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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Send Mail in C#.NET Window Application
Pintoo Yadav
May 12
2015
Code
1.4
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
private
void
button1_Click(
object
sender, EventArgs e)
{
sendEMailThroughHotMail();
// sendEMailThroughGmail();
}
public
void
sendEMailThroughHotMail()
{
try
{
//Mail Message
MailMessage mM =
new
MailMessage();
mM.From =
new
MailAddress(
"
[email protected]
"
);
//receiver email id
mM.To.Add(
"
[email protected]
"
);
mM.Subject =
"Text H2H Mail"
;
File.Copy(
"D:\\ClientMgmtDb1.accdb"
,
"D:\\ClientMgmtDb21.accdb"
,
true
);
mM.Attachments.Add(
new
Attachment(@
"D:\\ClientMgmtDb21.accdb"
));
mM.Body =
"Log_Fole"
;
mM.IsBodyHtml =
true
;
// SmtpClient sC = new SmtpClient("smtp.WorldClient.com");
SmtpClient sC =
new
SmtpClient(
"192.168.100.10"
);
// SmtpClient.UseDefaultCredentials = true;
//mySmtpClient.Host = "192.168.100.10";
sC.Port = 25;
sC.Credentials =
new
NetworkCredential(
"
[email protected]
"
,
"pintoo@123"
);
sC.EnableSsl =
false
;
sC.Send(mM);
MessageBox.Show(
"Mail send Fuccessfully..Thanks"
);
mM.Dispose();
File.Delete(
"D:\\ClientMgmtDb21.accdb"
);
}
catch
(Exception ex)
{
MessageBox.Show(
"error"
);
}
}
Windows Application