Solved

Emails in a Winform Application

Posted on 2010-09-08
5
579 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
ID: 33629914

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
ID: 33629986
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
ID: 33630015
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
ID: 33630431
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
ID: 33633118
Thanks Junges and vusov.

0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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:…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

713 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