473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 <filenamebecuase 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)

Oct 29 '08 #1
1 3252
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" <Sa******@discussions.microsoft.comwrote in message
news:F7**********************************@microsof t.com...
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 <filenamebecuase 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)
Oct 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan M. Rose | last post by:
I am looking for a script that I can sit on an HTML server (Linux, Apache, PHP/Perl/Python/Etc.) that will allow me to do the following things: 1) Post news articles that consists of (i) a title...
2
by: Chuck | last post by:
I have a database that has a table in it with employee information (name, dob, email, etc). This is joined to a table that has tasks that are assigned to each individual that has a recurring date....
3
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the...
2
by: Stanley Cheung | last post by:
Hi all, I am developing the application for send emailing list, actually, i can perform to send a email 1 by 1 and do it on aspx page. I have a enquiry that how can the application change to...
0
by: ryan | last post by:
I've been tasked with consuming a Perl web service that was written by a person in a different department of my company. The problem is it's the guy's first attempt at web services and he doesn't...
4
by: number1.email | last post by:
I have tried the following code: FileName: index2.php --------------------------------- <? mail( "aaa@yahoo.com", "A", "B", "From: a...@aol.com" ); echo "Finished Emailing."; ?>
13
by: Giggle Girl | last post by:
Hi there, I am having a problem with the behavior of Firefox, where lefthand column content is not resized properly after it is "collapsed" and then "re-expanded". An online demo is available...
1
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem,...
8
by: marjbell | last post by:
I have a Access database of email addresses that I would like to mass email to customers. Can Access be used through Outlook? or can it just be done with Access? I know it is possible to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.