CDO message: text attachment corrupted

I am creating an email using a CDO object (and VB6, but it doesn't really matter).

With New CDO.Message
  .To = "<address>"
  .Subject = "Manifest test 8"
  .Organization = "<company>"
  .From = "<address>"
  .Sender = .From

  With .Configuration
    .Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
    .Fields(cdoSMTPServer).Value = "192.168.0.4"
    .Fields.Update
  End With

  With .AddAttachment("c:\import\customermanifestOURACCOUNT11122008110032.dat")
    .Fields(cdoContentDisposition).Value = "attachment; filename=""Consignor.dat"""
    .Fields.Update
  End With

  .Send
End With

      

As you can see, the message is blank and contains an attachment that I renamed in the email.

The attachment is a fixed width ASCII text file containing some data from our systems, one entry per line, separated by CRLF.

When the message is sent, all CRs are removed from the attachment, so the recipient receives a file that only has LFs and is therefore corrupted.

I tried to change ContentEncoding

to 7bit and base64, didn't work.

I tried to install ContentMediaType

for attachment text/plain

, didn't work.

I tried not to rename the attachment after adding it didn't work.

ContentMediaType

the attachment is set to a default application/octet-stream

, so I can't figure out why (and for some reason) it changes in the first place.

If I execute .SaveToFile()

on the attachment just after .Send()

, it saves a valid file to disk.

Is this a problem in my code, or is it a mail server setup or something else?

+1


source to share


3 answers


Okay, that was weird.

We used our gmail accounts to test this thing, specifically the gmail web interface. We clicked on the app links to save open files. And the files were corrupted.



Once we tried a few fat clients instead, everything turned out to be fine. All files download as expected without any glitches.

So my guess is that this is a bug in the gmail web interface (as opposed to the Gmail POP3 interface).

+2


source


I haven't used CDO for a long time, but I remember this problem was in the past. After trying differently, we realized that if the message body contained any content, the attachments were sent as expected.

Strange, I know.



try and let us know.

0


source


I had the same problem. I switched to Jmail and my CSV (text file) was now exactly the same as the original when I read it from gmail.

I compared the original message (in Gmail, the option is to view the original message) and found that with CDO.Message the attachment is not encoded very well, it is stored in text format and the email client does what it wants with It. With Jmail, the message is Base64 encoded, so it is kept in its original state from start to finish. Therefore, be careful when using CDO.Message with text file attachments! Try using Jmail (free) instead.

CDO.message: Content-Transfer-Encoding: quoted-printable

Jmail.message: Content-Transfer-Encoding: base64

0


source







All Articles