makala 发表于 2015-9-14 04:02:03

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
{

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.iyunv.com/detail/lwl563944808/3649189
  
  
页: [1]
查看完整版本: Winfrom 调用outlook 新建 发送邮件