使用 SMTP 类发送电子邮件而不是 Outlook 时,电子邮件大小会奇怪地增加
我正在发送一封带有附件的电子邮件 使用以下代码
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说,这种增加看起来像是 MIME 编码的开销
This increase looks like an overhead of MIME encoding to me
这里有一个猜测: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