Strange increase in email size using SMTP class to send an email as opposed to outlook

自作多情 提交于 2019-12-24 08:21:55

问题


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.


回答1:


This increase looks like an overhead of MIME encoding to me




回答2:


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



来源:https://stackoverflow.com/questions/2013567/strange-increase-in-email-size-using-smtp-class-to-send-an-email-as-opposed-to-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!