Solved

Emails in a Winform Application

Posted on 2010-09-08
5
580 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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