Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2006

Tip: Looking for answers? Try searching our database.

System.Net.Mail.SmtpClient and lost attachments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric Guthmann - 07 Apr 2006 17:02 GMT
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.
Christopher Reed - 08 Apr 2006 13:15 GMT
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.
Signature

Christopher A. Reed
"The oxen are slow, but the earth is patient."

> We're running into an intermittent problem with the
> System.Net.Mail.SmtpClient class in the .NET 2.0 Framework when working
[quoted text clipped - 48 lines]
> 5. The loss of attachments seem to occur most when the system is under
> some load.
Eric Guthmann - 08 Apr 2006 19:17 GMT
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

> 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.
[quoted text clipped - 51 lines]
>> 5. The loss of attachments seem to occur most when the system is under
>> some load.
Christopher Reed - 09 Apr 2006 13:53 GMT
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.
Signature

Christopher A. Reed
"The oxen are slow, but the earth is patient."

> Hi Christopher,
>
[quoted text clipped - 66 lines]
>>> 5. The loss of attachments seem to occur most when the system is under
>>> some load.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.