Solved

Emails in a Winform Application

Posted on 2010-09-08
5
576 Views
Last Modified: 2012-05-10
Hi,

I have a winforms application.
I am trapping some exceptions and want to mail those exceptions to my email fro ma winforms application.
I know that there is a System.net.mail to send the emails.
Can anyone send a link or code for this ?

Thanks in Advance.

0
Comment
Question by:rowternet
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 250 total points
Comment Utility

MailMessage mail = new MailMessage();
System.Net.Mail.
SmtpClient SmtpServer = new SmtpClient( ServerName );
SmtpServer.Port = port;
SmtpServer.Credentials = new System.Net.NetworkCredential( login, pwd );
SmtpServer.EnableSsl = useSSL;

mail.From = new MailAddress( FromAddress, HeaderFromAddress );
mail.To.Add( ToAddress );
mail.Subject = Subject;
mail.Body = Data;

SmtpServer.Send( mail );
0
 

Author Comment

by:rowternet
Comment Utility
Hi junges thanks for the reply.
I am new and not familiar with smtp.
How will i get the smtp information?
And our clients are located across USA. So , if i provide the smtp information of our smtp server wuld that be good?
Or does it change for each client?

SmtpClient  same as smtp host?
can i get teh smtpinformation by issuing a command?
Thanks
0
 
LVL 14

Expert Comment

by:Daniel Junges
Comment Utility
yes, you can get the smtp settings from your email client and pass them here.
obs.: if you want to use gmail acount then you must first activate pop3 on the preference from gmail account.
0
 
LVL 3

Assisted Solution

by:vusov
vusov earned 250 total points
Comment Utility
Please review my Logger based on the log4net library it allows to send emails on fails. There is samle WinForms application, that shows how to use it. Logger is configured in the Program class and called in the Form1. Pay attention to the app.config where Loggers configurations.
In the LoggerNet project you can find ServerMail class that sends emails using specific credentials

LoggerNET.zip
0
 

Author Closing Comment

by:rowternet
Comment Utility
Thanks Junges and vusov.

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now