向大型 dl 发送电子邮件未成功完成。可能出了什么问题

问题描述 投票:0回答:1

我有发送电子邮件的代码,它适用于单个电子邮件和一个小 dl(5 封电子邮件),但大 dl 无法发送,没有任何失败信息。 似乎没有异常,而且我没有看到 send 返回任何成功或失败的信息。 如何获取有关大型 dl(该 dl 的 28 封单独电子邮件)失败原因的更多信息?来自脚本的邮件服务器中的 dl 中的电子邮件数量是否有最大限制?大型 dl 从 Outlook 运行。我在网上搜索过,但没有看到这样的东西。

static string mailTO(List<string> mailToList, string attachment, int errorCount, List<string> errorLines, DateTime buildDateTimeStamp, string processName, string subject, string description, List<string> desc2, string desc3)
{
    string mailClient = "client.net";   //this is our client.  Use yours to recreate

    string mailStatus = string.Empty;

    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
    message.IsBodyHtml = false;
    if (mailToList.Count == 0)
    {
        // If the mail to list did not contain any addresses, add the default address.
        message.To.Add(defaultMailTo);
    }
    else
    {
        // Add all of the addresses on the list
        foreach (string mailTo in mailToList)
        {
            // Attempt to add each address to the collection. If the add fails,
            // usually because of an unexpected email address format, an exception will be thrown.
            // If the address is not valid, test to see if it is a file name that contains 
            // a list of email addresses.
            try
            {
                message.To.Add(mailTo);
            }
            catch (Exception ex)
            {
                mailStatus += string.Format("Failed to include \"{0}\" - {1}\n", mailTo, ex.Message);
            }
        }
    }

    message.SubjectEncoding = System.Text.Encoding.UTF8;


    message.Subject = string.Format( subject );

    // Build the message body
    message.Body = description + "\n";
    
    message.Body += (string)desc3;

    message.From = new System.Net.Mail.MailAddress(s_mailFrom);
    message.ReplyToList.Add(s_mailFrom);

    if (File.Exists(attachment))
        message.Attachments.Add(new System.Net.Mail.Attachment(attachment));

    try
    {
        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(mailClient);
        smtp.Send(message);
    }
    catch (IOException ioex)
    {
        Console.WriteLine("FAILED to send mail, " + ioex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", ioex.Message);
    }
    catch (ArgumentNullException nex)
    {
        Console.WriteLine("FAILED to send mail, " + nex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", nex.Message);
    }
    catch (ObjectDisposedException oex)
    {
        Console.WriteLine("FAILED to send mail, " + oex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", oex.Message);
    }
    catch (InvalidOperationException iex)
    {
        Console.WriteLine("FAILED to send mail, " + iex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", iex.Message);
    }
    catch (SmtpFailedRecipientsException fsex)
    {
        Console.WriteLine("FAILED to send mail, " + fsex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", fsex.Message);
    }
    catch (SmtpFailedRecipientException fex)
    {
        Console.WriteLine("FAILED to send mail, " + fex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", fex.Message);
    }
    catch (SmtpException sex)
    {
        Console.WriteLine("FAILED to send mail, " + sex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", sex.Message);
    }
    catch (Exception ex)
    {
        Console.WriteLine("FAILED to send mail, " + ex.Message);
        mailStatus += string.Format("FAILED to send mail - {0}\n", ex.Message);
    }

    return mailStatus;
}
c# smtp send system.net.mail
1个回答
0
投票

我发现了问题所在。 DL 的最大电子邮件数量是 5000,所以不是这个数量。 在与我公司的 IT 部门讨论后,我发现了此链接:允许外部发件人。 当我的 IT 团队选中 DL 设置复选框后,我就用我的脚本进行了测试,并且电子邮件已成功发送。

© www.soinside.com 2019 - 2024. All rights reserved.