Model view controller 值不能为null。在asp.net mvc中发送hotmail或outlook电子邮件时的参数名称innerstream

Model view controller 值不能为null。在asp.net mvc中发送hotmail或outlook电子邮件时的参数名称innerstream,model-view-controller,outlook,hotmail,Model View Controller,Outlook,Hotmail,我在asp.net mvc中使用hotmail或outlook电子邮件发送smtp:smtp-mail.outlook.com的电子邮件。它在本地运行良好,但当尝试发送live时,会出现以下错误:“值不能为null。参数名innerstream”。请提出解决方案。谢谢你在阿达瓦奇。 下面是我的代码,它在本地运行得非常完美 ------------------------------------这是我的密码------------------------- 公共静态字符串SendMail(字符串发

我在asp.net mvc中使用hotmail或outlook电子邮件发送smtp:smtp-mail.outlook.com的电子邮件。它在本地运行良好,但当尝试发送live时,会出现以下错误:“值不能为null。参数名innerstream”。请提出解决方案。谢谢你在阿达瓦奇。 下面是我的代码,它在本地运行得非常完美

------------------------------------这是我的密码-------------------------

公共静态字符串SendMail(字符串发件人、字符串发件人名称、字符串[]收件人、字符串主题、字符串正文、字符串_smtp、字符串_autEmail、字符串_autPass、字符串ReplyTo=”“) {


显示生成并发送消息的相关代码片段。@DmitryStreblechenko我已附上我的代码,请检查。
        try
        {

         ComponentInfo.SetLicense("EN-2020Apr13-bFAW7hA9RPNwz2EimPfupBFO+Zvn7eAJFmwMDry8bw3XBOwrbN8zT5uOUMlwhwErECColZkcu0J9Nnp+k91PYjA+yVw==A");

            MailMessage message = new MailMessage();
            message.From.Add(new MailAddress(from, SenderName));
            foreach(var to in recipient)
            {
                message.To.Add(new MailAddress(to.Trim()));
            }
            
            if (!string.IsNullOrEmpty(ReplyTo))
            {
                message.To.Add(new MailAddress(ReplyTo.Trim()));
            }

            message.Subject = subject;             
            message.BodyHtml = body;

        RemoteCertificateValidationCallback validationDelegate =
        (object sender,
         X509Certificate certificate,
         X509Chain chain,
         SslPolicyErrors errors) =>
        {
            if (errors == SslPolicyErrors.None || errors == SslPolicyErrors.RemoteCertificateNameMismatch)
            {                 
                return true;
            }
            else
            {                  
                return false;
            }
        };

            // Create new SmtpClient and specify host, port, security and certificate validation callback.
            using (SmtpClient smtp = new SmtpClient(
                _smtp,
                465,
                ConnectionSecurity.Auto,
                validationDelegate))
            {
                smtp.Connect();
                smtp.Authenticate(_autEmail, _autPass, SmtpAuthentication.Login);
                smtp.SendMessage(message);
                return "1";
            }
        }
        catch (Exception ex)
        {
            return ex.Message;
        }

    }