• C# 调用outlook 发送邮件 或添加附件发送


    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();

  • 相关阅读:
    Codeforces Round #563 (Div. 2)B;Ehab Is an Odd Person
    Codeforces Round #563 (Div. 2)C. Ehab and a Special Coloring Problem
    Codeforces Round #567 (Div. 2) A.Chunga-Changa
    Codeforces Round #569 (Div. 2) B. Nick and Array
    Codeforces Round #570 (Div. 3) B. Equalize Prices
    2019年银联极客挑战赛第一题
    js点击保存图片
    vant地区三级联动
    input 输入金额正则判断
    git 实用命令
  • 原文地址:https://www.cnblogs.com/hijack/p/1687324.html
Copyright © 2020-2023  润新知