![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||