CDO.AddAttachment Problem

CDO.AddAttachment Problem

Post by robert.l.j » Wed, 08 Mar 2006 05:45:25


I have a .ASP page that allows users to upload a file to a SQL Server
database in Image format. From there, I have a VB6 application that
queries this table, writes the file using ADODB.Stream, and attaches
the document to an email using objMail.AddAttachment. This works fine
75% of the time.

Occassionally, I encounter a problem where the email looks like the
following:

Date: Fri, 24 Feb 2006 06:28:21 -0600
Message-ID: <000601c6393d$cc889810$ XXXX@XXXXX.COM >
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0007_01C6390B.81EE2810"
X-Mailer: Microsoft CDO for Windows 2000
Thread-Index: AcY5Pcxp2seUW02LSL2g0g7LH/bzDQ==
Content-Class: urn:content-classes:message
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
X-OriginalArrivalTime: 24 Feb 2006 12:28:21.0596 (UTC)
FILETIME=[CCA791C0:01C6393D]

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C6390B.81EE2810
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0008_01C6390B.81EE2810"


------=_NextPart_001_0008_01C6390B.81EE2810
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

MESSAGE BODY

------=_NextPart_001_0008_01C6390B.81EE2810
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

MESSAGE BODY

------=_NextPart_001_0008_01C6390B.81EE2810--

------=_NextPart_000_0007_01C6390B.81EE2810
Content-Type: application/octet-stream;
name="filename.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="filename.xls"

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAEAAAAAQAAAAAAAAAA
EAAAbwEAAAQAAAD+////AAAAAAAAAABiAAAA4wAAAIABAAD/////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////9
////bgEAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8A
AAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAA
AB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACQAAAAlAAAAJgAAACcAAAAoAAAAKQAAACoAAAArAAAA
LAAAAC0AAAAuAAAALwAAADAAAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAA6
AAAAOwAAADwAAAA9AAAAPgAAAD8AAABAAAAAQQAAAEIAAABDAAAARAAAAEU
...
...
...


Any ideas why some emails are corrupted and some are not?

Thanks,
Robert
 
 
 

CDO.AddAttachment Problem

Post by Anthony Jo » Thu, 09 Mar 2006 22:43:27


0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAEAAAAAQAAAAAAAAAA
EAAAbwEAAAQAAAD+////AAAAAAAAAABiAAAA4wAAAIABAAD/////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////9
////bgEAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8A
AAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAA
AB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACQAAAAlAAAAJgAAACcAAAAoAAAAKQAAACoAAAArAAAA
LAAAAC0AAAAuAAAALwAAADAAAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAA6

What makes you think this is corrupted. Looks like correct base64 encoding
to me

Anthony.

 
 
 

CDO.AddAttachment Problem

Post by robert.l.j » Sat, 11 Mar 2006 05:46:04

This is supposed to be a .xls attachment. I don't understand why when
I use objEmail.AddAttachment it writes the file to the email body like
this.
 
 
 

CDO.AddAttachment Problem

Post by Anthony Jo » Sat, 11 Mar 2006 08:02:38


This header:-

Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0007_01C6390B.81EE2810"

Says that the body of the email has mutliple parts. Each part is seperated
by the boundary value ----=_NextPart_000_0007_01C6390B.81EE2810

then:-

------=_NextPart_000_0007_01C6390B.81EE2810
Content-Type: application/octet-stream;
name="filename.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="filename.xls"

This indicates that a new bodypart is about to begin. The headers show that
the part is encoded as base64 and is an attachment with the nominal file
name of filename.xls.

It all seems to be in order.

Anthony.
 
 
 

CDO.AddAttachment Problem

Post by robert.l.j » Sat, 11 Mar 2006 08:43:41

If all is in order, then why isn't the document attached to the email
rather than being written to the body?
 
 
 

CDO.AddAttachment Problem

Post by robert.l.j » Sat, 11 Mar 2006 08:58:10

If all is in order, then why isn't the document attached to the email
rather than being written to the body?
 
 
 

CDO.AddAttachment Problem

Post by Anthony Jo » Sat, 11 Mar 2006 17:11:55


Robert,

An SMTP mail message is utlimately a simple stream of of bytes.

This message is a mime multipart message.

The document IS attached. What I described to you is how attachments work
in an mime multipart messages.

What were you expecting it to look like?

Anthony.
 
 
 

CDO.AddAttachment Problem

Post by robert.l.j » Sun, 12 Mar 2006 01:15:45

The message should just contain the email body with a document attached
and the standard link to download the attachment. These messages do
not have a link to download the attachment. Instead, the attachment is
written to the body in base64. The email body contains all of the MIME
header information. How do I make it quit doing that?? When these
messages are received, they just look like a bunch of base64 garbage
and not an actual document.

This is actually in the message body!

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAEAAAAAQAAAAAAAAAA

EAAAbwEAAAQAAAD+////AAAAAAAAAABiAAAA4wAAAIABAAD/////////////////////////////
 
 
 

CDO.AddAttachment Problem

Post by robert.l.j » Sun, 12 Mar 2006 02:34:02

I think I've found the problem. There was a line-feed at the end of my
subject.
 
 
 

CDO.AddAttachment Problem

Post by Anthony Jo » Sun, 12 Mar 2006 05:04:46


Ahh I see. I thought you were showing the raw data but you were actually
showing us the what an email program thought was the body.