发送带有zip文件夹附件的电子邮件而不是zip文件夹附件

时间:2020-07-22 15:10:14

标签: c# asp.net-mvc smtpclient

从服务器下载文件然后通过电子邮件发送它们后,我试图附加一个zip文件。

我在这里下载文件:

SysCallError: (10060, 'WSAETIMEDOUT')

SSLError: ("bad handshake: SysCallError(10060, 'WSAETIMEDOUT')",)

SSLError: HTTPSConnectionPool(host='api.census.gov', port=443): Max retries exceeded with url: /data/timeseries/qwi/sa?get=agegrp,Emp,EarnS,Payroll,EmpEnd,sex&for=county:*&in=state:01&key=b05d7f297ecfa142229364f2c6fe0b21cd5b8bfd&time=from%201996-Q1%20to%201996-Q4&industry=316&ownercode=A05 (Caused by SSLError(SSLError("bad handshake: SysCallError(10060, 'WSAETIMEDOUT')")))

然后,DBQueries.SendEmail函数会将我发送到这里,这是我遇到麻烦的地方。如何使下载的文件正确使用此功能?

else if (radio[0] == "Email Statements")
            {
                // Make array of emails into List for sending in email 
                if (emails.ToString() != "")
                {
                    var allEmails = emails[0].Split(',');

                    foreach (var email in allEmails)
                    {

                        if (emailValid.IsMatch(email))
                        {
                            everyEmail.Add(email);
                        }
                        else
                        {
                            return Json(new { success = false, message = $"* Not valid email address: {email}.\n\n * Please double check and try again." });
                        }
                        List<string> distinctFiles = allPaths
                            .GroupBy(x => x.Split(new char[] { '\\' }).Last())
                            .Select(x => x.First())
                            .ToList();
                        using (ZipFile zip = new ZipFile())
                        {
                            zip.AddFiles(distinctFiles, @"\");
                            MemoryStream output = new MemoryStream();
                            zip.Save(output);
                            //return File(output.ToArray(), "application/zip");
                            DBQueries.SendEmail(everyEmail, output, fromAddress, "Client Statement Reports", "Here are your requested Client Statements", true);

                        }

0 个答案:

没有答案
相关问题