Results 1 to 4 of 4

Thread: sending an e-mail

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    sending an e-mail

    Hello,

    I am trying to create an e-mail application. I have created a simple mail application in win forms. The user will put in the fields and click the send button.

    I am not really sure how an e-mail application works. But if send an e-mail to my e-mail account i.e. [email protected]. I send the e-mail. However, I never receive the e-mail that I send using this mail application. The application works ok, and there are no run-time errors. Is there something I need to do, to be able to send this to my hotmail, yahoo, or gmail e-mail accounts.

    The code I have used is below. This has been written in C# Visual Studio 2005.

    Thanks in advance

    Code:
    using System.Web.Mail;
    
    private void btnSend_Click(object sender, EventArgs e)
            {
                try
                {
                    //Construct a new mail message and fill it with information from the form
                    MailMessage aMessage = new MailMessage();
                    aMessage.From = txtFrom.Text;
                    aMessage.To = txtTo.Text;
                    aMessage.Cc = txtCC.Text;
                    aMessage.Bcc = txtBCC.Text;
                    aMessage.Subject = txtSubject.Text;
                    aMessage.Body = txtMessage.Text;
    
                    //If an attachment file is indicated, create it and add it to the message
                    if (txtAttachment.Text.Length > 0)
                    {
                        aMessage.Attachments.Add(new MailAttachment(txtAttachment.Text, MailEncoding.Base64));
                    }
    
                    //Now send the message
                    SmtpMail.Send(aMessage);
    
                    //Indicate that the message has been sent
                    MessageBox.Show("Message sent to " + txtTo.Text, "E-mail Program", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
    steve

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: sending an e-mail

    hmmmm.....

    Is the default mail server configured correctly for sending mail?
    If you open IIS do you see a list of mails in the queue waiting to be sent?

  3. #3
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: sending an e-mail

    im having the problem of the mail sitting in the queue flder also.
    if you get it sorted let me know
    it works 60% of the time, all the time.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: sending an e-mail

    Hello

    I have just found some useful information. I have configured the IIS smtp virtual server.

    In the general settings l have add my IP address.

    In the access tab, click rely button and granted access to the localhost. On connection l have granted access to the localhost as well.

    I have added this code:
    Code:
    SmtpMail.SmtpServer = "localhost";
    or
    SmtpMail.SmtpServer = "127.0.0.1";
    But l am still getting the same error message "Transport failed to connect to server".

    I tried putting this code it:
    Code:
    SmtpMail.SmtpServer.Insert(0,"localhost");
    I don't get the erorr this time, but no mail is received in my yahoo account.
    This application uses winforms.

    Any ideas on how to solve this.

    Many thanks,

    Steve
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width