|
-
Mar 5th, 2006, 12:12 PM
#1
Thread Starter
Frenzied Member
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());
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|