Re: System.Net.Mail.SmtpClient and lost attachments



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.







.



Relevant Pages

  • Re: System.Net.Mail.SmtpClient and lost attachments
    ... think this can be the problem since a resend of the very same email and ... PDF files). ... About 10% of the emails sent via this class are missing ... Dim ms As New MemoryStream ...
    (microsoft.public.dotnet.framework)
  • System.Net.Mail.SmtpClient and lost attachments
    ... We're running into an intermittent problem with the ... PDF attachments (it may be any attachment, ... About 10% of the emails sent via this class are missing their ... Dim ms As New MemoryStream ...
    (microsoft.public.dotnet.framework)
  • RE: NEW SBS2003 INSTALLATION ON EXISTING NETWORK
    ... Does this allow users on the LAN to send and receive emails over the Internet ... Probably configuring network shares and transferring across the network. ... but using the SBS wizards makes it easier still. ... >> requires SBS2003 with Windows XP clients. ...
    (microsoft.public.windows.server.sbs)
  • Re: Print a stored PDF file
    ... CONTAINER: If I display or print the PDF in it's container, ... Export the PDF file from its container to disk. ... They print the Purchase Order with the invoice because the payer ... send two emails: one with the invoice attached and one with the ...
    (comp.databases.filemaker)
  • Outlook rules puzzle for clever people....help please!
    ... With Network A, I can only access emails while physically in the office. ... It is trivially easy to do this on Hetwork A, by configuring an Outlook ... rule on Network B to redirect or forward all messages to Network A. ...
    (microsoft.public.outlook)

Quantcast