English 中文(简体)
发送电子邮件信标会增加信标档案尺寸。
原标题:Sending an email attatchment increases the attatchments file size in .net

I am currently working a piece of code which needs to send an attachment in the email it generates. The attachment is a PDF document. Due to requirements I am unable to save the PDF and send it, so I have had to create a memory stream attachment.

The issue I have with this is that the file size is _500KB. However save the file on my machine and it is around 370KB.

This increase in file size is unacceptable. has anyone come across this issue before? If so how have they got round the problem.

Below is the section of code.

Dim memStream As System.IO.MemoryStream = Nothing
 assign number to the PDF name
Dim filename As String = req.GetAccountNumber()
 add file extension
filename &= ".pdf"

 initialise the memory stream
memStream = New System.IO.MemoryStream()

 generate the pdf and put it in a byte array
Dim arrBytData() As Byte = CType(PDFRequest(),Byte()))

 flush the stream
memStream.Flush()

 Create new instances of the message and attachments
 and intialise them
Dim msg As New System.Net.Mail.MailMessage(req.EmailFrom, req.EmailTo)
Dim att As New System.Net.Mail.Attachment(memStream, filename)

With msg
     .Attachments.Add(att)
     .Body = req.EmailBody
     .Subject = req.EmailSubject
End With

 connect to the server and send the message
Dim client As New System.Net.Mail.SmtpClient()
client.Host = PDFService(Of T).mSMTPServer
client.Send(msg)

 Close our stream
memStream.Close()
msg = Nothing
最佳回答

问题在于,附件必须编码为基地64-原始二元数据在电子邮件中打上“保险”,因此必须编码为一种只使用某些“安全”特性的形式。 这增加了2 566个“果园”,而第64基地的编码只有64个。 这实际上不是任何办法。

问题回答

增加的原因可能是,在电子邮件所附的双元数据基64编码。 AFAIK在这方面没有任何东西可以做。





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签