C#实现调用本地邮件软件发邮件

来源:互联网 发布:tensorflow官方文档 编辑:程序博客网 时间:2024/06/16 18:15
public void MenuItem_SendEmail(object sender, EventArgs e)//发送邮件        {            //RegistryKey pRegKey = Registry.CurrentUser;            //pRegKey = pRegKey.OpenSubKey("Software//Microsoft//office//outlook");            RegistryKey pRegKey = Registry.ClassesRoot.OpenSubKey(@"mailto/shell/open/command");            if (pRegKey == null)            {                MessageBox.Show("你没有安装任何邮件发送软件,该功能需要依赖邮件发送软件/r/t请确认已安装该类软件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);                return;            }            else            {                string path = pRegKey.GetValue("").ToString();                int length =path.LastIndexOf(" ");                path = path.Substring(0,length);                path = path.Replace("/"", "");                pRegKey.Close();                String email = String.Empty;                email = AccountEmail(this._accountGrid);                if (email == String.Empty)                {                    MessageBox.Show("你选中的客户没有填写油箱!");                    return;                }                try                {                    System.Diagnostics.Process.Start(path, "mailto:" + email);                }                catch                 {                    MessageBox.Show("邮件发送软件没有安装正确");                }            }                   }
原创粉丝点击