login about faq

I have an issue decrypting the message. I created a certificate using the following command. makecert -sk Mynewkey -n "CN=TestCert" test.cer -ss my -pe

Error at this following line. mime.GetPart(1) is null. Error message with LastErrorText is : Failed to get MIME message part

Here is my decryption code.

        Chilkat.Mime mime = new Chilkat.Mime();

        // Any string passed to UnlockComponent begins the 30-day trial
        mime.UnlockComponent("30-day trial");
        if (result != null)
        // Unwrap the security.  
        // The results are stored within the Mime object and can be queried
        // afterwards. 
        // The UnwrapSecurity does all decryption and signature validation,
        // regardless of how complex the MIME message may be.
        bool decryptSuccess = mime.UnwrapSecurity();

        if (decryptSuccess == false)

        // Save the decrypted MIME message.
        // (You can convert any MIME message to XML too.)

        // Get the first encrypting certificate.
        // In complex cases where the MIME is nested and contains
        // other encrypted MIME messages, there will be more than
        // one encrypting certificate.
        Chilkat.Cert cert;
        cert = mime.GetEncryptCert(0);

        // This example uses a MIME message that included a GIF attachment.
        // Save the GIF to a file.
        Chilkat.Mime gifAttachment;
        gifAttachment = mime.GetPart(1);

asked Dec 10 '12 at 15:43

nav100's gravatar image


Look at the contents of the MIME after unwrapping the security layers (i.e. after calling UnwrapSecurity). Is the MIME multipart? If not, then obviously there are no sub-parts. If so, is there only 1 sub-part? The first sub-part is at index 0.

Also, make sure you understand the very basics of MIME -- such as: What is a multipart MIME message.

Also, to view the MIME, either save it to a file via the SaveMime method, or write it to a string via the GetMime method.


answered Dec 10 '12 at 15:50

chilkat's gravatar image

chilkat ♦♦

Thank you. It is multipart message. mime.GetPart(0) works. How can I extract message if there are multiple files? In this example I know this is .gif file. How can I find the file type and save it to disk? Could you please let me know.

(Dec 10 '12 at 17:24) nav100
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: Dec 10 '12 at 15:43

Seen: 1,765 times

Last updated: Dec 10 '12 at 17:24

powered by OSQA