zoukankan      html  css  js  c++  java
  • Winfrom 调用outlook 新建 发送邮件

    需求:

          如图1,需要在窗口中点击一个邮件链接地址(或其它事件触发)然后能够打开自己机器上的Outlook的新建邮件窗口,如图2

                                        图1

                                                                  图2

    实现步骤:

    1.新建调用发送邮件类

    /**************************************************
    * 文 件 名:SendMail.cs
     
    * 所属模块:PatentFocus.DAL
    * 文件功能:用于调用用户自己机器上的邮箱客户端,新建邮件
    *          
    *
    * 创 建 人:罗万里
    * 创建日期:2011-09-29
    * 修 改 人:
    * 修改日期:
    * 备    注:
    * ************************************************/
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;
    namespace WindowsCharTest
    {
        /// <summary>
        /// 新建邮件发送
        /// </summary>
        public class SendMail
        {
            [DllImport("shell32.dll", EntryPoint = "ShellExecuteA")]
            public static extern int ShellExecute(
             int hwnd,
             String lpOperation,
             String lpFile,
             String lpParameters,
             String lpDirectory,
             int nShowCmd
             );
        }
    }

    2.调用

    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                try
                {
                    SendMail.ShellExecute(0, String.Empty, "mailto:邮箱地址", String.Empty, String.Empty, 1);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("未找到符合要求的邮箱客户端支持此功能!");
                }
            }     

    ------------------------------------------------------------------------

     linkLabel1 :为如图1中显示邮箱地址的linkLable

    需要源码的可到CSDN上下载,下载地址为:http://download.csdn.net/detail/lwl563944808/3649189

     

     

  • 相关阅读:
    SPOJ LCS2
    SPOJ NSUBSTR
    1977: [BeiJing2010组队]次小生成树 Tree
    2002: [Hnoi2010]Bounce 弹飞绵羊
    P3690 【模板】Link Cut Tree (动态树)
    P2093 [国家集训队]JZPFAR
    2648: SJY摆棋子
    HDU 2966 In case of failure
    bzoj 一些题目汇总
    BZOJ3653谈笑风生——可持久化线段树+dfs序
  • 原文地址:https://www.cnblogs.com/luowanli/p/2639905.html
Copyright © 2011-2022 走看看