473,513 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CDO--Failure transmitting PDF as attachment via email from VB, VBA

I am using CDO to email a file as an attachment. The receiver receives
the file, but when he opens the file (tried using both Acrobat Reader
6 and 5), he gets "There was an error opening this document. The file
is damaged and could not be repaired." (similar error on Acrobat
Reader 5--Root object is missing) This pdf file opens fine on the
workstation from where I am transmitting. I have tried other pdf
files, but exact problem happens with all the pdf files. I tried
copying this suppossedly damaged file to other machine, assuming the
machine on which I am opening has Acrobat installed incorrectly, but
on other machines also, I get the same error. I also tried putting
sleep before sending, assuming that would solve the problem, but of no
avail. I tried transmitting other types of files, such as txt, mdb,
dbf, and exe. Those transmit fine and open correctly on the receiving
end. Just as a note that the size of the pdf file on the receiving end
changes (though slightly--increases). I know this is not good, but I
am not doing anything, which would change the size.

Could anybody help me solve this problem, so I can successfully
transmit pdf files, using CDO?

Thanks
---------------
Public Sub EmailPDF()
Dim iMsg, iConf, Flds, Fld
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields
iMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
iMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "smarthost"
iMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25

With iMsg
Set .Configuration = iConf
.To = """User A"" <ab*@xyz.com>"
.From = """User B"" <de*@xyz.com>"
.Subject = "Attached Doc"
.AddAttachment "c:\abc.pdf"
.send
End With
Nov 13 '05 #1
3 4694
In your sample code you do not appear to be using Flds anywhere:

Set Flds = iConf.Fields

and iConf is just an object of type "CDO.Configuration"

With iMsg
Set .Configuration = iConf

I honestly don't know anything about CDO applications, but a lot of
times I find answers to things from questions. You appear to be setting
the configurations.Fields.Item of your message object, iMsg, here:

iMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusing") = 2
iMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserver") = "smarthost"
iMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserverport") = 25

would that be your Flds object? I am not seeing the connection between
iMsg and iConf. Comparing this to Excel, it seems like you are setting
a Range object to Excel.Range but you are not assigning any parameters
to it like rng = Range("A1:D5"), just rng.

Set iMsg.Configuration = iConf

set rng = Excelobj

Hope these questions help you find your answer.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
On 23 Jul 2004 07:35:45 -0700, gu*****@yahoo.com (gudia) wrote:
I am using CDO to email a file as an attachment. The receiver receives
the file, but when he opens the file (tried using both Acrobat Reader
6 and 5), he gets "There was an error opening this document. The file
is damaged and could not be repaired." (similar error on Acrobat
Reader 5--Root object is missing) This pdf file opens fine on the
workstation from where I am transmitting. I have tried other pdf
files, but exact problem happens with all the pdf files. I tried
copying this suppossedly damaged file to other machine, assuming the
machine on which I am opening has Acrobat installed incorrectly, but
on other machines also, I get the same error. I also tried putting
sleep before sending, assuming that would solve the problem, but of no
avail. I tried transmitting other types of files, such as txt, mdb,
dbf, and exe. Those transmit fine and open correctly on the receiving
end. Just as a note that the size of the pdf file on the receiving end
changes (though slightly--increases). I know this is not good, but I
am not doing anything, which would change the size.

Could anybody help me solve this problem, so I can successfully
transmit pdf files, using CDO?


Some thoughts...

Have you tried sending the file manually, without the programming? If
you can send it in Outlook or some other e-mail program, then if he
still gets the error, you've eliminated CDO as the cause.

If you can open the file fine on your side on several workstations,
it's remotely possible that something is happening to the MIME in an
intermediate gateway/e-mail server, OR (more likely) maybe something
is wrong with your friend's Acrobat Reader installation...

- snip -
_______________________
Michael B. Johnson
Nov 13 '05 #3
The problem is solved. The message body, which is missing, is
necessary. I do not know why but that solves the problem

Thanks everybody

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

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

Similar topics

2
3166
by: knoak | last post by:
Hi there, I've found a script at these great Google fora. a script to send emails with attachments. The script is below this message, name etc. aren't mine, but from the original post. My...
4
3722
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
4
306
by: Len | last post by:
Hi,SmtpMail.Send(email); I am trying to work thru some examples on webforms. I can't get the email portion to work."SmtpMail.Send(email)"; I have xppro, visual studio academic, and...
0
1702
by: amallik | last post by:
//The following 3 lines of codes necessary if smtp server needs authenticatio mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication for smtp...
9
4189
by: deepaks85 | last post by:
Dear Sir, I have created a simple request form which will be mailed to me. Now I want to attach files and send it through that request form. For this I am using the following script: ...
3
2991
by: jambonjamasb | last post by:
Hi I have two tables: email_tbl Data_table Data table is is used to create a Form Data_form
3
1416
by: mturner64 | last post by:
I'm working on a simple web app to send email. Below is my code: Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub SubmitButton_Click(ByVal...
1
3285
by: metalforever | last post by:
How do you redirect a form after submit(form sends email) ? This is pretty urgent for me. I have included the code in a pastebin. http://pastebin.org/249014 process_form sends the email. ...
4
5038
by: luke noob | last post by:
This is my HTML... <head> <script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script> <script type="text/javascript" src="js/script.js"></script> </head> <body>
0
7267
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
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
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
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.