473,500 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP CDOSYS SMTP Email attachments are being corrupted

I have an ASP page that uses CDOSYS to send a simple HTML format email with a
PDF attachment. When I open the PDF attached to the email it shows up as a
blank page. I log into the web server console and open the same PDF in the
source directory and it opens fine. I run a binary comparison of the source
and attached files and there's a difference: one byte, x'2E' is missing at
offset x'0231'. If I save the attached file and use a hex editor to insert
the x'2E' the file opens just like the original.

Any ideas? I'm baffled...
Mar 27 '06 #1
4 12212

"rschaeferhig" <rs**********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I have an ASP page that uses CDOSYS to send a simple HTML format email with a PDF attachment. When I open the PDF attached to the email it shows up as a
blank page. I log into the web server console and open the same PDF in the
source directory and it opens fine. I run a binary comparison of the source and attached files and there's a difference: one byte, x'2E' is missing at
offset x'0231'. If I save the attached file and use a hex editor to insert
the x'2E' the file opens just like the original.

Any ideas? I'm baffled...


Windows 2003 server right?

I've come across this at a few of my client's sites but I haven't found out
why it happens. I seems that CDOSYS ends up using binary encoding rather
than Base64 encoding when creating the attachment body part. It doesn't
happen all system though.

In the end I just used the following code to create the attachment myself:-
Function AddAttachment(Message, Source, FileName, MimeType)

Dim oPart ' As IBodyPart
Dim oStreamIn ' As ADODB.Stream
Dim oStreamOut ' As ADODB.Stream

Set oPart = Message.Attachments.Add

oPart.ContentMediaType = MimeType & "; Name = """ & FileName & """"
oPart.ContentTransferEncoding = "base64"
oPart.Fields("urn:schemas:mailheader:content-disposition").Value =
"attachment; FileName = """ & FileName & """"
oPart.Fields.Update

Set oStreamIn = Server.CreateObject("ADODB.Stream")

oStreamIn.Open
oStreamIn.Type = adTypeBinary
oStreamIn.LoadFromFile Source

Set oStreamOut = oPart.GetDecodedContentStream

oStreamIn.CopyTo oStreamOut

oStreamOut.Flush

oStreamIn.Close

Set AddAttachment = oPart

End Function
Given a MyStuff.PDF in the folder C:\temp this function is called as:-

Dim oMsg

Set oMsg = Server.CreateObject("CDO.Message")

'Set From, To, etc.
oMsg.TextBody = "Blah Blah"

AddAttachment oMsg, "c:\temp\MyStuff.pdf", "MyStuff.pdf", "application/pdf"

oMsg.Send

HTH

Anthony.
Mar 27 '06 #2


"Anthony Jones" wrote:

"rschaeferhig" <rs**********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I have an ASP page that uses CDOSYS to send a simple HTML format email

with a
PDF attachment. When I open the PDF attached to the email it shows up as a
blank page. I log into the web server console and open the same PDF in the
source directory and it opens fine. I run a binary comparison of the

source
and attached files and there's a difference: one byte, x'2E' is missing at
offset x'0231'. If I save the attached file and use a hex editor to insert
the x'2E' the file opens just like the original.

Any ideas? I'm baffled...


Windows 2003 server right?

I've come across this at a few of my client's sites but I haven't found out
why it happens. I seems that CDOSYS ends up using binary encoding rather
than Base64 encoding when creating the attachment body part. It doesn't
happen all system though.

In the end I just used the following code to create the attachment myself:-
Function AddAttachment(Message, Source, FileName, MimeType)

Dim oPart ' As IBodyPart
Dim oStreamIn ' As ADODB.Stream
Dim oStreamOut ' As ADODB.Stream

Set oPart = Message.Attachments.Add

oPart.ContentMediaType = MimeType & "; Name = """ & FileName & """"
oPart.ContentTransferEncoding = "base64"
oPart.Fields("urn:schemas:mailheader:content-disposition").Value =
"attachment; FileName = """ & FileName & """"
oPart.Fields.Update

Set oStreamIn = Server.CreateObject("ADODB.Stream")

oStreamIn.Open
oStreamIn.Type = adTypeBinary
oStreamIn.LoadFromFile Source

Set oStreamOut = oPart.GetDecodedContentStream

oStreamIn.CopyTo oStreamOut

oStreamOut.Flush

oStreamIn.Close

Set AddAttachment = oPart

End Function
Given a MyStuff.PDF in the folder C:\temp this function is called as:-

Dim oMsg

Set oMsg = Server.CreateObject("CDO.Message")

'Set From, To, etc.
oMsg.TextBody = "Blah Blah"

AddAttachment oMsg, "c:\temp\MyStuff.pdf", "MyStuff.pdf", "application/pdf"

oMsg.Send

HTH

Anthony.

Mar 27 '06 #3
Oops.

Windows 2000 Server AND Windows 2003 Server, but I'll give it a shot. I
suspected an encoding problem, I've just never had any experience doing my
own encoding so I had no idea where to start.

thanks.

"Anthony Jones" wrote:

"rschaeferhig" <rs**********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I have an ASP page that uses CDOSYS to send a simple HTML format email

with a
PDF attachment. When I open the PDF attached to the email it shows up as a
blank page. I log into the web server console and open the same PDF in the
source directory and it opens fine. I run a binary comparison of the

source
and attached files and there's a difference: one byte, x'2E' is missing at
offset x'0231'. If I save the attached file and use a hex editor to insert
the x'2E' the file opens just like the original.

Any ideas? I'm baffled...


Windows 2003 server right?

I've come across this at a few of my client's sites but I haven't found out
why it happens. I seems that CDOSYS ends up using binary encoding rather
than Base64 encoding when creating the attachment body part. It doesn't
happen all system though.

In the end I just used the following code to create the attachment myself:-
Function AddAttachment(Message, Source, FileName, MimeType)

Dim oPart ' As IBodyPart
Dim oStreamIn ' As ADODB.Stream
Dim oStreamOut ' As ADODB.Stream

Set oPart = Message.Attachments.Add

oPart.ContentMediaType = MimeType & "; Name = """ & FileName & """"
oPart.ContentTransferEncoding = "base64"
oPart.Fields("urn:schemas:mailheader:content-disposition").Value =
"attachment; FileName = """ & FileName & """"
oPart.Fields.Update

Set oStreamIn = Server.CreateObject("ADODB.Stream")

oStreamIn.Open
oStreamIn.Type = adTypeBinary
oStreamIn.LoadFromFile Source

Set oStreamOut = oPart.GetDecodedContentStream

oStreamIn.CopyTo oStreamOut

oStreamOut.Flush

oStreamIn.Close

Set AddAttachment = oPart

End Function
Given a MyStuff.PDF in the folder C:\temp this function is called as:-

Dim oMsg

Set oMsg = Server.CreateObject("CDO.Message")

'Set From, To, etc.
oMsg.TextBody = "Blah Blah"

AddAttachment oMsg, "c:\temp\MyStuff.pdf", "MyStuff.pdf", "application/pdf"

oMsg.Send

HTH

Anthony.

Mar 27 '06 #4
I had the same problem, have you tried sending via CDNOTS?

Sanj

"rschaeferhig" wrote:
Oops.

Windows 2000 Server AND Windows 2003 Server, but I'll give it a shot. I
suspected an encoding problem, I've just never had any experience doing my
own encoding so I had no idea where to start.

thanks.

"Anthony Jones" wrote:

"rschaeferhig" <rs**********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I have an ASP page that uses CDOSYS to send a simple HTML format email

with a
PDF attachment. When I open the PDF attached to the email it shows up as a
blank page. I log into the web server console and open the same PDF in the
source directory and it opens fine. I run a binary comparison of the

source
and attached files and there's a difference: one byte, x'2E' is missing at
offset x'0231'. If I save the attached file and use a hex editor to insert
the x'2E' the file opens just like the original.

Any ideas? I'm baffled...


Windows 2003 server right?

I've come across this at a few of my client's sites but I haven't found out
why it happens. I seems that CDOSYS ends up using binary encoding rather
than Base64 encoding when creating the attachment body part. It doesn't
happen all system though.

In the end I just used the following code to create the attachment myself:-
Function AddAttachment(Message, Source, FileName, MimeType)

Dim oPart ' As IBodyPart
Dim oStreamIn ' As ADODB.Stream
Dim oStreamOut ' As ADODB.Stream

Set oPart = Message.Attachments.Add

oPart.ContentMediaType = MimeType & "; Name = """ & FileName & """"
oPart.ContentTransferEncoding = "base64"
oPart.Fields("urn:schemas:mailheader:content-disposition").Value =
"attachment; FileName = """ & FileName & """"
oPart.Fields.Update

Set oStreamIn = Server.CreateObject("ADODB.Stream")

oStreamIn.Open
oStreamIn.Type = adTypeBinary
oStreamIn.LoadFromFile Source

Set oStreamOut = oPart.GetDecodedContentStream

oStreamIn.CopyTo oStreamOut

oStreamOut.Flush

oStreamIn.Close

Set AddAttachment = oPart

End Function
Given a MyStuff.PDF in the folder C:\temp this function is called as:-

Dim oMsg

Set oMsg = Server.CreateObject("CDO.Message")

'Set From, To, etc.
oMsg.TextBody = "Blah Blah"

AddAttachment oMsg, "c:\temp\MyStuff.pdf", "MyStuff.pdf", "application/pdf"

oMsg.Send

HTH

Anthony.

Mar 29 '06 #5

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

Similar topics

21
3971
by: tp | last post by:
HI..... I have made simpale web site inside that i am generating email page which send form as email. i have setup small business server with Exchange server 2003 and i have hosted my website...
9
3007
by: RedMoosh | last post by:
is it possible to rn a client side vbscript to send messages using cdo.message and cdo.configuration? what are the requirements to do this? my wks are xp and 2000 and all have cdosys.dll...
10
19504
by: Jed | last post by:
I have a form that needs to handle international characters withing the UTF-8 character set. I have tried all the recommended strategies for getting utf-8 characters from form input to email...
1
2405
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an...
12
2189
by: Basr | last post by:
My provider removed suddenly the CDONTS from the server. Now I have to change my forms and I have to use the CDOSYS functionaltity Till now I used one script that could do the work with one page....
8
7533
by: Akbur | last post by:
Dear all, I'm having major issues sending an email from my ASP.NET app. I'm getting a "Could not create 'CDO.Message' object". When I did a search for cdosys.dll in \win_location\system32, I...
8
3244
by: worldofrugs | last post by:
I'm hosted on a shared server with Godaddy.com... I have several forms on my website that all use the same ASP file to send out my forms.. It worked fine for a long time, but now the forms send to...
4
7200
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am working on a program that gets mail messages from the default SMTP server with iis 6.0 on windows server 2003. I am using the cdosys.dll in the system32 directory. The reference Name is...
7
16865
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on...
0
7153
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
7215
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
7245
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...
1
6919
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...
0
5510
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4939
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
3115
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3113
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
686
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.