[Mono-list] Send mail with mono

Dana Epp dana at vulscan.com
Sun Mar 26 15:31:12 EST 2006

Point your code to any SMTP server that will allow you to send through
it (aka, your ISPs mail server). Then just use code like this:

Code SNIPPIT >>>

using System.Diagnostics;
using System.Web.Mail;

public bool SendEmail( string emailAddr, string smtpServer, string
subject, string body )  
	bool ret = false;

	MailMessage msg = new MailMessage();
	msg.To = emailAddr;
	msg.From = "your at email.addr";
	msg.Subject = subject;

		SmtpMail.SmtpServer = smtpServer;
		SmtpMail.Send( body );
		ret = true;
	catch( Exception e )
		System.Diagnostics.Debug.Writeline( "Failed to send
email. Error: " + e.Message );
		ret = false;
	return ret;	


This is off the top of my head, so if it doesn't compile... don't yell
at me. And you would obviously check the validity of all those
parameters. But that will let you email from a mod_mono web application.
It doesn't care what mail server you set up or use. 

Dana Epp 
[Microsoft Security MVP]

-----Original Message-----
From: mono-list-bounces at lists.ximian.com
[mailto:mono-list-bounces at lists.ximian.com] On Behalf Of fedotenko
Sent: Sunday, March 26, 2006 11:43 AM
To: mono-list at lists.ximian.com
Subject: [Mono-list] Send mail with mono

What email-program is needed to be able to send mail with mono? I tried
installing sendmail, without success, and wonder if there is an easier
probgram to install to be able to send mail via an mod_mono
View this message in context:
Sent from the Mono - General forum at Nabble.com.

Mono-list maillist  -  Mono-list at lists.ximian.com

More information about the Mono-list mailing list