Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Emails in a Winform Application

Posted on 2010-09-08
5
Medium Priority
?
584 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 1000 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 1000 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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