简体   繁体   English

如何使用 CDO.Message 在经典 ASP 中从 Windows Docker Z5DA5ACF461B4EFB7E7ZEC801916 发送 email

[英]How to use CDO.Message to send email in Classic ASP from Windows Docker IIS 2019

My team is tasked with migrating a Classic ASP application from a Windows 2008 Server to a Docker container ( mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 ), with as little code-change as possible.我的团队的任务是将经典 ASP 应用程序从 Windows 2008 服务器迁移到 Docker 容器 ( mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 ),代码更改尽可能少。 The application uses Server.CreateObject("CDO.Message") to send email.应用程序使用Server.CreateObject("CDO.Message")发送 email。

That line, however, results in the following error: 006~ASP 0177~Server.CreateObject Failed~800401f3/ .但是,该行会导致以下错误: 006~ASP 0177~Server.CreateObject Failed~800401f3/ I am given to understand from this thread , that this is because the cdosys.dll file is missing from this Windows Docker image.我从这个线程中了解到,这是因为这个 Windows Docker 图像中缺少 cdosys.dll 文件。

It appears that the cdosys.dll file is absent in Windows Docker images, generally.通常,Windows Docker 图像中似乎不存在 cdosys.dll 文件。 I tried installing just a ton of windows features (everything .NET that was available), but none of them appear to contain this file.我尝试只安装大量 windows 功能(所有可用的 .NET),但它们似乎都不包含此文件。 A team member has attempted to manually register the dll, as well, without success.一名团队成员也尝试手动注册 dll,但未成功。

How can I use CDO.Message to send email from my Windows Docker container?如何使用 CDO.Message 从我的 Windows Docker 容器发送 email?

Make a wrapper class that implements the CDO.MESSAGE API.制作实现 CDO.MESSAGE API 的包装器 class。

We wrapped around System.Net.Mail我们围绕 System.Net.Mail

using System.Net.Mail;
using System.Runtime.InteropServices;

namespace AspClassicMail
{
    [System.Runtime.InteropServices.ComVisible(true)]
    [ProgId("AspClassicMail.Message")]
    public class Message
    {
        private MailMessage mailMessage;

        public string To {
            get
            {
                return mailMessage.To.ToString(); 
            }
            set {
                mailMessage.To.Clear();
                mailMessage.To.Add(value.Replace(';', ','));
            }
        }

        public string Subject {
            get
            {
                return mailMessage.Subject;
            }
            set
            {
                mailMessage.Subject = value;
            }
        }

        public string CC
        {
            get
            {
                return mailMessage.CC.ToString(); 
            }
            set
            {
                mailMessage.CC.Clear();
                mailMessage.CC.Add(value.Replace(';', ','));
            }
        }

        public string Bcc
        {
            get
            {
                return mailMessage.Bcc.ToString();
            }
            set
            {
                mailMessage.Bcc.Clear();
                mailMessage.Bcc.Add(value.Replace(';', ','));
            }
        }

        public string From
        {
            get
            {
                return mailMessage.From.Address;
            }
            set
            {
                mailMessage.From = new MailAddress(value);
            }
        }

        public string ReplyTo
        {
            get
            {
                return mailMessage.ReplyToList.ToString();
            }
            set
            {
                mailMessage.ReplyToList.Clear();
                mailMessage.ReplyToList.Add(value.Replace(';',','));
            }
        }

        public string textbody
        {
            get
            {
                return mailMessage.Body;
            }
            set
            {
                mailMessage.IsBodyHtml = false;
                mailMessage.Body = value;
            }
        }

        public string HTMLBody
        {
            get
            {
                return mailMessage.Body;
            }
            set
            {
                mailMessage.IsBodyHtml = true;
                mailMessage.Body = value;
            }
        }

        public Message()
        {
            mailMessage = new MailMessage();
        }

        public void send()
        {
            SmtpClient smtpClient = new SmtpClient("YOUR MAIL SERVER");
            smtpClient.Send(mailMessage);
        }
    }
}

You may need to include a property for "Configuration" as well.您可能还需要包含“配置”的属性。 We just removed the configuration from the ASP files instead.我们只是从 ASP 文件中删除了配置。

You can either place it in an MSI package and set the DLL class to Register "vsdrpCOM" or run RegAsm.exe from your .NET framework folder. You can either place it in an MSI package and set the DLL class to Register "vsdrpCOM" or run RegAsm.exe from your .NET framework folder.

ASP Classic code just needs updated to replace Server.CreateObject("CDO.Message") with Server.CreateObject("AspClassicMail.Message")只需更新 ASP Classic 代码即可将Server.CreateObject("CDO.Message")替换为Server.CreateObject("AspClassicMail.Message")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 服务器 2019 和 IIS 10 GET、POST 工作正常但不能从外部使用 PUT、DELETE - Windows server 2019 and IIS 10 GET,POST work fine but can't use PUT,DELETE from external 从Windows到Linux传输ASP经典页面 - Transfering ASP Classic Pages from Windows to Linux 如何配置服务器以发送电子邮件,IIS Windows Server 2008上安装了PHP - How can I configure my server to send email, PHP installed on IIS Windows Server 2008 如何使用 Windows Server 2019 在 IIS 10 上托管 Node JS 应用程序 - How to host Node JS app on IIS 10 with Windows Server 2019 如何从 Windows 批处理文件发送简单的电子邮件? - How to send a simple email from a Windows batch file? 如何在Windows上打开端口25从本地主机发送电子邮件 - How to open port 25 to send email from localhost on windows 如何使用 docker 在 windows server 2019 中使用 nginx 设置反向代理? - How to setup reverse proxy with nginx in windows server 2019 using docker? 我的新Windows Server 2019 iis上没有默认网站将ASP.NET Hello World发布到 - no default web site on my new Windows Server 2019 iis to publish an ASP.NET hello world to 如何在Windows Server 2016/2019的Jenkins中运行Docker构建? - How to run Docker builds in Jenkins on Windows Server 2016/2019? 无法在 windows 服务器 2019 中运行 docker 容器 - Cannot run docker container in windows server 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM