• 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

     

     

  • 相关阅读:
    Ubuntu双系统
    Qt实现 动态化遍历二叉树(前中后层次遍历)
    Qt学习资料
    Qt学习--信号与槽(多窗口的实现)
    Qt 学习-----helloword
    二叉树的前中后层次遍历
    悬浮在网页右侧并可依次展开的菜单导航
    js实现仿华为手机计算器,兼容电脑和手机屏幕
    jquery json实现面向对象 百度十二星座
    knova绘制进度条
  • 原文地址:https://www.cnblogs.com/luowanli/p/2639905.html
Copyright © 2020-2023  润新知