Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How to Send Mail in C#.NET Window Application
WhatsApp
Pintoo Yadav
May 12
2015
1.5
k
0
0
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
Up Next
How to Send Mail in C#.NET Window Application