使用 SMTP 类发送电子邮件而不是 Outlook 时,电子邮件大小会奇怪地增加

发布于 2024-08-17 03:41:45 字数 785 浏览 4 评论 0原文

我正在发送一封带有附件的电子邮件 使用以下代码

Dim msg As New System.Net.Mail.MailMessage(req.EmailFrom, req.EmailTo)
            Dim att As New System.Net.Mail.Attachment("C:\Documents and Settings\michaelr\Desktop\1216259.pdf")
            With msg
                .Attachments.Add(att)
                .Body = req.EmailBody
                .Subject = req.EmailSubject
            End With
    Dim client As New System.Net.Mail.SmtpClient()
            client.Host = PDFService(Of T).mSMTPServer
            client.Send(msg)

收件人收到电子邮件后,附件的文件大小为396KB 显示文件大小为 543Kb。 奇怪的是,如果我使用 Outlook 发送带有相同附件的电子邮件,文件大小为 396KB。

据我所知,由于附件采用 Base 64 编码,文件大小可能会增加 而不仅仅是原始二进制文件。

我不明白的是为什么 Outlook 发送一个大小为 396KB 的文件,但在代码中 发送它,相同的文件有543Kb。

任何帮助将不胜感激,并获得一个绿色的大勾号。

I am sending an email with an attachment
using the following Code

Dim msg As New System.Net.Mail.MailMessage(req.EmailFrom, req.EmailTo)
            Dim att As New System.Net.Mail.Attachment("C:\Documents and Settings\michaelr\Desktop\1216259.pdf")
            With msg
                .Attachments.Add(att)
                .Body = req.EmailBody
                .Subject = req.EmailSubject
            End With
    Dim client As New System.Net.Mail.SmtpClient()
            client.Host = PDFService(Of T).mSMTPServer
            client.Send(msg)

The file size of the attachment is 396KB, upon the recipient receiving the email outlook
shows the file size as 543Kb.
Strange thing is if I send an email with the same attachment using outlook the file size is
396Kb.

I understand that file sizes can increase due to the attachment being base 64 encoded
as opposed to just raw binary.

What I am failing to see is why outlook send a file which is 396KB in size but in code when
sending it, the same file is 543Kb.

Any help would be appreciated and get a big green tick.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悸初 2024-08-24 03:41:45

对我来说,这种增加看起来像是 MIME 编码的开销

This increase looks like an overhead of MIME encoding to me

走过海棠暮 2024-08-24 03:41:45

这里有一个猜测:Outlook 可能会对附件执行某种压缩,或者可能使用比内置 MailMessage 类更有效的编码机制。

更新:看起来 Outlook 使用专有的编码机制: http://support.microsoft.com/kb/290809

Here's a guess: Outlook may perform some kind of compression on the attachment, or may use a more efficient encoding mechanism than the built-in MailMessage class does.

UPDATE: Looks like Outlook uses a proprietary encoding mechanism: http://support.microsoft.com/kb/290809

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文