Is there a simple way to send an email in C# without any extra DLLs?

Any help on this would be appreciated.

Thanks

SiPex

Recommended Answers

All 2 Replies

using System.Net.Mail;


        public static string sendMail(string theBody, string toEmail, string fromEmail, string subject, string aReturn)
        {
            try
            {
                MailMessage tempMess =
                    new MailMessage(fromEmail, toEmail,
                                    subject, theBody);
                tempMess.IsBodyHtml = true;
                SmtpClient tempClient = new SmtpClient();
                tempClient.Send(tempMess);
                return aReturn;
            }
            catch (Exception E)
            {
                return E.ToString();
            }

        }

You need something like this in the webconfig


<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="from@host.com">
<network host="mail.host.com" defaultCredentials="false" userName="email@hostcom" password="pass"/>
</smtp>
</mailSettings>
</system.net>

if you use VS 2003
add project->reference->System.Web.Net;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.