login about faq

I am using the MailMan and the Mime components to send encrypted and signed e-mail with an attachment. This has worked fine for several customers and in the test system for the customer in question.

Now we have gone into production and here we are using a new set of certificates for encryption and signing. The e-mails are sent without any problems. However, the recipient of the e-mails now reports that some of the attachments are padded with a lot of zeros (the example file I got is originally about 560kb, but what they get is about 970kb with 410kb of zeros).

All customers are communicating with the exact same system using the same software, so it's difficult to understand what's going on. I can see that the .eml file which we create (this is written to file just before we send it) is actually bigger than .eml-files created with bigger attachment files from other customers. This means that the problem is probably on our side. I don't have access to the certificates and the system we are communicating with, so it's hard for me to do any debugging (the system runs abroad within a secure network).

There is a possibility that my stream writer (see below) creates the zeros, but I want to ask if this is something that might have a logic explanation before digging deeper into this.

var msw = new MyStreamWriter();
using (var stream = new MemoryStream())
     msw.WriteToStream(stream, fileRepresentation);
     message.AddDataAttachment(message.Subject, stream.GetBuffer());

But just previous to this code we have used the same class to write it to a file instead of to an attachment, and that file gets the correct size.

Is there anything which can explain this behavior?

This is with ChilkatDotNet4.dll

asked Mar 24 '14 at 13:05

sdybvik's gravatar image


Test using the latest version of Chilkat (v9.5.0)

Using v9.5.0, examine the contents of the message.LastErrorText after calling AddDataAttachment. It should tell you the exact number of bytes you passed to it. (It will also show the filename you passed to it.) The LastErrorText always contains information, even for success cases -- which is to help understand what happened when the method succeeded, but did not do what was expected.


answered Mar 24 '14 at 13:13

chilkat's gravatar image

chilkat ♦♦

I used the mail.GetMimeObject() function, but this function is not available in 9.5.0. From the documentation it should be there.

Will this to the exact same?

var mimeBinary = message.GetMimeBinary();
var mime = new Mime();
(Mar 25 '14 at 08:09) sdybvik

Yes, that is what I would've suggested. The new reference documentation and release notes will be out this week. A few methods that cause cross-linkage between significant Chilkat classes have been removed. See http://www.cknotes.com/?p=540 for an explanation involving MHT.

The few methods that have been removed can be worked around by getting the string or bytes from an alternative method (such as GetMimeBinary) and then loading it into a new instance of the desired object.

Check to see if the problem remains using v9.5.0 with the snippet of code above. If so, then let me know...

(Mar 25 '14 at 08:23) chilkat ♦♦

The problem still remained with 9.5, but it wasn't your fault (as usual). It appears that the streams we created occasionally got some extra data in it and wrote this to the attachment. I have no clue why this happened (as I wasn't able to reproduce the issue), but by using the exact same way to produce the byte array for the attachment as for the file I wrote to disk it now seems to work.

Thank you for the support.

(Mar 26 '14 at 05:36) sdybvik
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Mar 24 '14 at 13:05

Seen: 2,637 times

Last updated: Mar 26 '14 at 05:36

powered by OSQA