Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Problem emailing PDF document from .net service

Reply
 
Old 10-29-2008   #1 (permalink)
Sai Vajja


 
 

Problem emailing PDF document from .net service

Hi

I am trying to send a .pdf document as an email attachment using net.mail.
This email is being sent by a windows service application. After i receive
the email, and when i try to open the attachment, i get the following error
message...

"adobe reader could not open <filename> becuase it is either not a
suppported file type or because the file has been damaged(for example, it was
sent as an email attachment and wasn't correctly decoded)"

Here is a glimpse of the code doing the emailing..

Dim Mail_Message As MailMessage = New MailMessage(objEmail.MailFrom,
objEmail.MailTo)
Dim Server_Name As SmtpClient = New SmtpClient(MailServer)
Dim Port_Number As Int32 = Convert.ToInt32(MailServerPortNumber)

With Mail_Message
.Body = Trim(objEmail.Message)
.Subject = Trim(objEmail.Subject)
.Priority = objEmail.Priority
.IsBodyHtml = True
.BodyEncoding = System.Text.Encoding.Unicode

For Each oAttachment As Attachment In objEmail.Attachments
.Attachments.Add(oAttachment) 'Here is where i am
attaching the file
Next

End With
Server_Name.Send(Mail_Message)


My System SpecsSystem Spec
Old 10-30-2008   #2 (permalink)
Mark S. Milley


 
 

Re: Problem emailing PDF document from .net service

Are you also generating the PDF file in your program? Is this segment being
triggered by a filesystemwatcher?

It's possible that you're attempting to send the PDF before it has been
fully generated. Verify this by comparing the version that you've received
in your inbox and with the version of the file that you're trying to send in
a hex reader. My bet is that there are some critical bits in the latter part
of the PDF that are missing from the version that was emailed.

If this is indeed the problem, the solution here is simply to wait until the
file is done being written to. Try using the System.IO library to open the
file exclusively. If you can't, then the file isn't ready. Wait a few
milliseconds and try again until the PDF is done.

Cheers,

-M

"Sai Vajja" <SaiVajja@xxxxxx> wrote in message
news:F7A70813-A94F-4005-BAF9-E41ADC0F1579@xxxxxx
Quote:

> Hi
>
> I am trying to send a .pdf document as an email attachment using net.mail.
> This email is being sent by a windows service application. After i receive
> the email, and when i try to open the attachment, i get the following
> error
> message...
>
> "adobe reader could not open <filename> becuase it is either not a
> suppported file type or because the file has been damaged(for example, it
> was
> sent as an email attachment and wasn't correctly decoded)"
>
> Here is a glimpse of the code doing the emailing..
>
> Dim Mail_Message As MailMessage = New MailMessage(objEmail.MailFrom,
> objEmail.MailTo)
> Dim Server_Name As SmtpClient = New SmtpClient(MailServer)
> Dim Port_Number As Int32 =
> Convert.ToInt32(MailServerPortNumber)
>
> With Mail_Message
> .Body = Trim(objEmail.Message)
> .Subject = Trim(objEmail.Subject)
> .Priority = objEmail.Priority
> .IsBodyHtml = True
> .BodyEncoding = System.Text.Encoding.Unicode
>
> For Each oAttachment As Attachment In objEmail.Attachments
> .Attachments.Add(oAttachment) 'Here is where i am
> attaching the file
> Next
>
> End With
> Server_Name.Send(Mail_Message)
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Puzzling problem emailing pictures w/Windows Mail? Browsers & Mail
Problem with a Service that Fails to Start (Bonjour Service) Vista General
Emailing a Word Document from Windows Live Mail Windows Live
Emailing Photos - Problem .NET General
Problem Emailing Photos from Photo Gallery Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46