473,395 Members | 1,948 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,395 software developers and data experts.

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 12200

"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
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
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
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
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
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
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
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
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
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.