Advertisement

05.09.2008 at 01:01PM PDT, ID: 23390683
[x]
Attachment Details

Error sending mail via SMTP in ASP.NET Class

Asked by attaylor44 in Simple Mail Transfer Protocol (SMTP), Programming for ASP.NET, Microsoft Visual C#.Net

Tags: c#, ASP.NET

I am trying to generate a class to send an email via SMTP, I am having no luck.  Any ideas?  Please see my class as defined below.  I catch an error of "Failure Sending Mail".  Thanks for any assistance!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
 
namespace GALawyer
{
    public class SendEmail
    {
 
        public static void SimpleEmail(string to, string from, string subject, string message)
        {
            try
            {               
 
                MailMessage msg = new MailMessage();
 
                msg.To.Add(to);
                
                msg.From = new MailAddress (from);
 
                msg.Subject = subject;
                msg.Body = message;
 
                SmtpClient mySmtp = new SmtpClient("HOST");
 
                 
 
                mySmtp.Send(msg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 
 
 
 
    }
 
    
}
 
Loading Advertisement...
 
[+][-]05.09.2008 at 01:38PM PDT, ID: 21536262

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 09:56PM PDT, ID: 21541516

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.13.2008 at 05:56AM PDT, ID: 21554525

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Simple Mail Transfer Protocol (SMTP), Programming for ASP.NET, Microsoft Visual C#.Net
Tags: c#, ASP.NET
Sign Up Now!
Solution Provided By: attaylor44
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628