views:

274

answers:

2

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  A: 

This increase looks like an overhead of MIME encoding to me

DmitryK
+1  A: 

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

Dave Swersky
The proprietary encoding is switched on when creating a Rich Text email, this isn't the case.I have a feeling that outlook is doing something which the MailMessage class does not. The difference in size is pretty much the size of increase that you would expect with Mime Type encoding.Which leaves me to wonder wether there is something, I can use either in my class, or at the exchange side, that can do a similar thing.
Miker169