Thread: Help with Sending Emails

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    4

    Help with Sending Emails

    hi all,

    i wrote a program that's supposed to me Like a mailer

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Net.Mail;
    using System.Web;
    
    namespace CS.NET_Mailer
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void btn_Send_Click(object sender, EventArgs e)
            {
               
                MailAddress from = new MailAddress(txtFrom.Text);
                
                MailAddress to = new MailAddress(txtTo.Text);
               
                MailMessage mMsg = new MailMessage();
                mMsg.From = from;
                mMsg.To.Add(to);
    
                mMsg.Subject = txtSubject.Text;
                mMsg.Body = txtBody.Text;
                SmtpClient smtp = new SmtpClient("127.0.0.1");
                try
                {
                    smtp.Send(mMsg);
                }
                catch (SmtpException)
                {
                    MessageBox.Show("Failed ! ");
                }
    
    
                
            }
        }
    }
    it always "Failed ! " .

    The Project is here :
    http://www.rogepost.com/n/2420010321

    so any ideas ?
    Last edited by StrikerX; 04-24-2007 at 05:04 PM.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    You should check what the exception message is.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    8
    is 127.0.0.1 a valid SmtpClient?
    you do know you have to run one on your pc to make it work, right? :-)

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    4
    i've tried with it and it was all about the SmptClient .

    thanx nvoigt & ShadowBeast .

    it's now working : )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending data - line by line?
    By tuckker in forum C Programming
    Replies: 0
    Last Post: 02-21-2009, 09:31 PM
  2. Sending Email - Using System.Net.Mail
    By b4ip in forum C# Programming
    Replies: 1
    Last Post: 06-01-2007, 12:34 AM
  3. Sending emails through a windows application/openGL
    By two31d in forum C++ Programming
    Replies: 5
    Last Post: 01-28-2006, 02:48 AM
  4. Sending emails
    By ventolin in forum C++ Programming
    Replies: 5
    Last Post: 05-08-2004, 06:23 AM
  5. Question - Emails - Viruses
    By MethodMan in forum Tech Board
    Replies: 2
    Last Post: 12-30-2002, 04:57 PM