Solved

Emails in a Winform Application

Posted on 2010-09-08
5
582 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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