0

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

Any help on this would be appreciated.

Thanks

SiPex

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Ramy Mahrous
0
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>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.