代码之家  ›  专栏  ›  技术社区  ›  Matthias

以C格式将mime编码的文件作为电子邮件发送#

  •  2
  • Matthias  · 技术社区  · 15 年前

    我有一个问题,我有一个包含所有相关邮件信息(主题、发件人、收件人等)的mime编码文件,我想通过c_通过一个定义好的smtp服务器发送它。

    我查看了mailmessage类并搜索了一个解决方案,但找不到合适的解决方案。你能帮我吗?

    谢谢, 马蒂亚斯

    3 回复  |  直到 13 年前
        1
  •  0
  •   Martin Vobr    14 年前

    标准.NET框架的当前版本不支持它afaik。但是,在大多数第三方邮件组件中都会发现这样的功能。

    以下代码使用我们的 Rebex Mail 图书馆。

    using Rebex.Net; // Smtp class
    using Rebex.Mail; // contains the MailMessage and other classes 
    
    // create an instance of MailMessage 
    MailMessage message = new MailMessage();
    
    // load the message from a local disk file 
    message.Load("c:\\message.eml");
    
    Smtp.Send(message, "smtp.example.org");
    

    代码取自 Rebex SMTP Tutorial Rebex MailMessage tutorial .

        2
  •  0
  •   Pawel Lesnikowski    15 年前

    您可以使用 Mail.dll email component :

    IMail email = new CreateFromEmlFile("c:\\email.eml");
    
    using(Smtp smtp = new Smtp())
    {
        smtp.Connect("smtp.company.com");
        smtp.Ehlo(HeloType.EhloHelo, "Mail.dll");
        smtp.Login("user", "password");
    
        smtp.SendMessage(email);
    
        smtp.Close(false);
    }
    

    请注意,mail.dll是我创建的商业产品。

        3
  •  -1
  •   Tim Cooper    13 年前

    一句话“不”。

    您必须解析该文件,提取数据,并设置mailmessage对象的各种属性。

    如果您要从mime内容创建或加载mailmessage对象,那么在框架中就没有任何方法可以实现这一点。