书宇软件
书宇教育教学软件--出题助手
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Web.Mail;

namespace MyMail
{
    
/// <summary>
    
/// Summary description for Form1.
    
/// </summary>

    public class Form1 : System.Windows.Forms.Form
    
{
        
private System.Windows.Forms.Label label1;
        
private System.Windows.Forms.Label label2;
        
private System.Windows.Forms.Label label3;
        
private System.Windows.Forms.Label label4;
        
private System.Windows.Forms.TextBox txtSender;
        
private System.Windows.Forms.TextBox txtRecipient;
        
private System.Windows.Forms.TextBox txtSubject;
        
private System.Windows.Forms.TextBox txtText;
        
private System.Windows.Forms.TextBox txtAttachments;
        
private System.Windows.Forms.Button btnAttachments;
        
private System.Windows.Forms.Button btnSend;
        
private System.Windows.Forms.OpenFileDialog openFileDialog1;
        
private System.Windows.Forms.Button btnExit;

        MailMessage message 
= new MailMessage();
        
/// <summary>
        
/// Required designer variable.
        
/// </summary>

        private System.ComponentModel.Container components = null;

        
public Form1()
        
{
            
//
            
// Required for Windows Form Designer support
            
//
            InitializeComponent();

            
//
            
// TODO: Add any constructor code after InitializeComponent call
            
//
        }


        
/// <summary>
        
/// Clean up any resources being used.
        
/// </summary>

        protected override void Dispose( bool disposing )
        
{
            
if( disposing )
            
{
                
if (components != null
                
{
                    components.Dispose();
                }

            }

            
base.Dispose( disposing );
        }


        
Windows Form Designer generated code

        
/// <summary>
        
/// The main entry point for the application.
        
/// </summary>

        [STAThread]
        
static void Main() 
        
{
            Application.Run(
new Form1());
        }


        
private void btnCancel_Click(object sender, System.EventArgs e)
        
{
            Application.Exit();
        }


        
private void btnAttachments_Click(object sender, System.EventArgs e)
        
{
            openFileDialog1.ShowDialog();
            MailAttachment attachment  
= new MailAttachment(openFileDialog1.FileName);
            txtAttachments.Text 
= txtAttachments.Text + openFileDialog1.FileName;
            message.Attachments.Add(attachment);
        }


        
private void btnSend_Click(object sender, System.EventArgs e)
        
{
            message.From 
= txtSender.Text;
            message.To 
= txtRecipient.Text;
            message.Subject 
= txtSubject.Text;
            message.Body 
= txtText.Text;
            SmtpMail.Send(message);
            MessageBox.Show(
"邮件成功发送!");
        }

    }

}

 
程序附图片如下








posted on 2005-10-21 15:54  可可先生  阅读(244)  评论(0编辑  收藏  举报