最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#調(diào)用OutLokk實(shí)現(xiàn)發(fā)送郵件

 更新時(shí)間:2022年12月27日 09:11:49   作者:芝麻粒兒  
這篇文章主要為大家詳細(xì)介紹了如何利用C#調(diào)用OutLokk實(shí)現(xiàn)發(fā)送郵件的功能,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下

實(shí)踐過程

效果

代碼

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    #region 查找與指定文件關(guān)聯(lián)在一起的程序的文件名
    /// <summary>
    /// 查找與指定文件關(guān)聯(lián)在一起的程序的文件名
    /// </summary>
    /// <param name="hwnd">窗口句柄</param>
    /// <param name="lpOperation">指定字串“open”來打開lpFlie文檔,或指定“Print”來打印它</param>
    /// <param name="lpFile">想用關(guān)聯(lián)程序打印或打開一個(gè)程序名或文件名</param>
    /// <param name="lpParameters">如lpszFlie是可執(zhí)行文件,則這個(gè)字串包含傳遞給執(zhí)行程序的參數(shù)</param>
    /// <param name="lpDirectory">想使用的完整路徑</param>
    /// <param name="nShowCmd">定義了如何顯示啟動程序的常數(shù)值</param>
    /// <returns>非零表示成功,零表示失敗</returns>
    [DllImport("shell32.dll", EntryPoint = "ShellExecuteA")]
    public static extern int ShellExecute(
     IntPtr hwnd,
     String lpOperation,
     String lpFile,
     String lpParameters,
     String lpDirectory,
     int nShowCmd
     );
    #endregion

    private void button1_Click(object sender, EventArgs e)
    {
        if (textBox1.Text != "")
        {
            if (Regex.IsMatch(textBox1.Text, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"))
                ShellExecute(this.Handle, String.Empty, "mailto:" + textBox1.Text, String.Empty, String.Empty, 1);
            else
            {
                MessageBox.Show("請輸入正確的郵箱格式");
                textBox1.Text = string.Empty;
            }
        }
    }
}
partial class Form1
{
    /// <summary>
    /// 必需的設(shè)計(jì)器變量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的資源。
    /// </summary>
    /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗體設(shè)計(jì)器生成的代碼

    /// <summary>
    /// 設(shè)計(jì)器支持所需的方法 - 不要
    /// 使用代碼編輯器修改此方法的內(nèi)容。
    /// </summary>
    private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();
        this.label1 = new System.Windows.Forms.Label();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(128, 41);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(152, 23);
        this.button1.TabIndex = 1;
        this.button1.Text = "調(diào)用OutLook對其發(fā)送";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(12, 15);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(77, 12);
        this.label1.TabIndex = 1;
        this.label1.Text = "郵件接收人:";
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(95, 12);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(185, 21);
        this.textBox1.TabIndex = 0;
        this.textBox1.Text = "mingrisoft@mingrisoft.com";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292, 74);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.button1);
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "調(diào)用OutLook發(fā)送郵件";
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox textBox1;
}

到此這篇關(guān)于C#調(diào)用OutLokk實(shí)現(xiàn)發(fā)送郵件的文章就介紹到這了,更多相關(guān)C# OutLokk發(fā)送郵件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

兴化市| 出国| 南靖县| 穆棱市| 沂水县| 常州市| 阿勒泰市| 新巴尔虎左旗| 新河县| 江孜县| 西安市| 兴山县| 会泽县| 五常市| 霍城县| 龙泉市| 开江县| 凤山县| 梁河县| 镶黄旗| 会宁县| 达日县| 星子县| 平湖市| 西城区| 林芝县| 平远县| 当阳市| 新巴尔虎右旗| 中方县| 邹城市| 定襄县| 会宁县| 鹤峰县| 上杭县| 泽库县| 华蓥市| 高碑店市| 东安县| 普兰店市| 阿拉善右旗|