Re: System.Net.Mail.SmtpClient and lost attachments
- From: "Christopher Reed" <carttu@xxxxxxxxxxxxx>
- Date: Sun, 9 Apr 2006 07:53:08 -0500
Then your issue with network load may be the issue. You may be sending some
of these on top of each other because the network is loaded and slower.
What you might consider is putting a time lag in your Windows Service app to
ensure that each individual email has been sent and given enough time to be
received by the mail server.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."
"Eric Guthmann" <eric@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OvVTkizWGHA.3332@xxxxxxxxxxxxxxxxxxxxxxx
Hi Christopher,
Thanks for the reply. The actual attachments are well below the
attachment cutoff size (they are always between 50KB and 150KB in size).
I also don't think this can be the problem since a resend of the very same
email and attachment works just fine.
At this point, I think it must be an issue in the SmtpClient class itself
since everything is sent to the Send method in the same manner each time,
and we have verified with additional code that the attachment is there
each time before calling the Send method.
Thanks,
Eric
"Christopher Reed" <carttu@xxxxxxxxxxxxx> wrote in message
news:Os$$cYwWGHA.3660@xxxxxxxxxxxxxxxxxxxxxxx
You might want to verify the attachment cutoff size for the mail server.
Your problem may actually be associated with these PDFs being too large.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."
"Eric Guthmann" <eric@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23I7QhylWGHA.2268@xxxxxxxxxxxxxxxxxxxxxxx
We're running into an intermittent problem with the
System.Net.Mail.SmtpClient class in the .NET 2.0 Framework when working
with PDF attachments (it may be any attachment, but we're working with
PDF files). About 10% of the emails sent via this class are missing
their attachment. We have verified everything on our side prior to the
handoff to the SmtpClient.Send method, and have even tried resending
those emails that are received with no attachment and it subsequently
works fine.
Has anyone else seen this issue, and if so, is there a workaround?
Dim ms As New MemoryStream
'' ....
'' Generate PDF document into the memory stream
'' ....
ms.Seek(0, SeekOrigin.Begin)
Dim mailAttachment As New Attachment(ms, "Attachment.pdf",
"application/pdf")
Dim msg As New MailMessage
msg.From = New MailAddress(emailFromAddress, emailFromName)
msg.Subject = subject
msg.To.Add(toAddress)
msg.Bcc.Add(bccAddress)
msg.Attachments.Add(mailAttachment)
Dim smtp As New SmtpClient(emailSmtpServer, emailSmtpPort)
Try
smtp.Send(msg)
Finally
'' we have also tried without the following dispose calls, but this
did not change the result
msg.Dispose()
mailAttachment.Dispose()
End Try
Here are the specifics:
1. The code is in a Windows Service running under the Network Service
account
2. It doesn't look like it has anything to do with the actual attachment
because emails that are missing the attachment can be resent without
problem
3. We're communicating with an Exchange 2000 server
4. We have added code to verify that the PDF was actually generated and
is well-formed. Everything looks good until the SmtpClient.Send call.
It is in this call that the attachment is sometimes lost.
5. The loss of attachments seem to occur most when the system is under
some load.
.
- References:
- System.Net.Mail.SmtpClient and lost attachments
- From: Eric Guthmann
- Re: System.Net.Mail.SmtpClient and lost attachments
- From: Christopher Reed
- Re: System.Net.Mail.SmtpClient and lost attachments
- From: Eric Guthmann
- System.Net.Mail.SmtpClient and lost attachments
- Prev by Date: Re: Namespace - in ASP.NET and libraries
- Next by Date: Re: Extending .net Regular Expressions
- Previous by thread: Re: System.Net.Mail.SmtpClient and lost attachments
- Next by thread: Loading private assemblies from a subdirectory
- Index(es):
Relevant Pages
|