[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;

	try
	{
		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;	
}

<<< End SNIPPIT

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. 


Regards,
Dana Epp 
[Microsoft Security MVP]
http://silverstr.ufies.org/blog/

-----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
webbapplication.
--
View this message in context:
http://www.nabble.com/Send-mail-with-mono-t1345628.html#a3599580
Sent from the Mono - General forum at Nabble.com.

_______________________________________________
Mono-list maillist  -  Mono-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


More information about the Mono-list mailing list