현재 생성 된 전자 메일의 첨부 파일을 보내야하는 코드를 작업하고 있습니다. 첨부 파일은 PDF 문서입니다. 요구 사항으로 인해 은 PDF를 저장하고 보낼 수 없으므로 메모리 스트림 첨부 파일을 만들어야했습니다.전자 메일 첨부 파일을 보내면 .net의 첨부 파일 크기가 늘어납니다.
내가 가진이 문제점은 파일 크기가 _500KB라는 것입니다. 그러나 내 컴퓨터에 파일을 저장하면 약 370KB입니다.
이러한 파일 크기의 증가는 용납되지 않습니다. 누구든지 전에이 문제를 보았습니까? 그렇다면 어떻게 문제를 해결할 수 있었습니까?
다음은 코드 섹션입니다. '
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
은 실제 코드입니까? 메모리 스트림을 어디에서 채우고 있습니까? –