惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
V
V2EX
Jina AI
Jina AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
量子位
L
LangChain Blog
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
腾讯CDC
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss

博客园 - vcool

HI C#解压RAR压缩文件 vb调用webservice 报表服务器无法打开与报表服务器数据库的连接 在WEB中实现打印分页 微软的面试题及答案-超变态但是很经典 C# 操作TIF AutoResetEvent和ManualResetEvent 篮球的各个位置的职能!!! WF 与 WCF 集成 六步使用ICallbackEventHandler实现无刷新回调 ArcGIS Server .Net Web ADF体系结构 ASP.NET中处理读写XML小结 我们期待自己成为一个优秀的软件模型设计者 XML实现异构数据库间转换的实现与分析 异构数据库 第九交响曲 利用ArcGIS Engine、VS .NET和Windows控件开发GIS应用 如何创建强命名程序集
C# 调用outlook 发送邮件 或添加附件发送 - vcool
vcool · 2010-03-04 · via 博客园 - vcool

1.

这个是不调用IE Mailto 来发送的,调用win API来

Mailto.ShellExecute(0, String.Empty, "mailto:vcool011@hotmail.com?subject=这是标题哦&body=这是文本内容啊!!!!!!!!! C:\\avatar.xml", String.Empty, String.Empty, 1);

class Mailto                       //与我联系打开邮箱的类
    {
        [DllImport("shell32.dll", EntryPoint = "ShellExecuteA")]
        public static extern int ShellExecute(
         int hwnd,
         String lpOperation,
         String lpFile,
         String lpParameters,
         String lpDirectory,
         int nShowCmd
         );

    }

2 调用 IE方法来

           System.Diagnostics.Process.Start("mailto:liuyi.aspnet@163.com?subject=这是标题哦&body=这是文本内容啊!!!!!!!!!");

前面二种都不能添加附件发送

下面是可以添加附件发送的

3

引用MSMAPI32.OCX 来实现,可添加附件

      MAPISession MAPIS1 = new MAPISession();
                MAPIMessagesClass MAPIM1 = new MAPIMessagesClass();
                MAPIS1.NewSession = true;
                MAPIS1.LogonUI = false;
                MAPIS1.DownLoadMail = false;

                string m_path;
                string m_file_name;
                string m_file;

                m_path = "c:\\";

                m_file_name = "Log.txt";
                m_file = m_path + m_file_name;

                MAPIS1.SignOn();

                MAPIM1.SessionID = MAPIS1.SessionID;
                MAPIM1.Compose();

                MAPIM1.AddressResolveUI = true;
                MAPIM1.AttachmentIndex = 0;

                MAPIM1.AttachmentPathName = m_file;
                MAPIM1.AttachmentName = m_file_name;

                MAPIM1.MsgSubject = "The Title ";
                MAPIM1.MsgNoteText = "The Body ";

                MAPIM1.Send(true);

                MAPIS1.SignOff();