librelist archives

« back to archive

CTCoreMessage initWithString usage

CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-03 @ 06:39
Hi,
I'm trying to create a CTCoreMessage with a content of a .eml file without
success. The file contains the following message:

> Subject: MySubject
> Mime-Version: 1.0 (Apple Message framework v1278)
> Content-Type: text/plain; charset=us-ascii
> From: MySender <mysender@mydomain.com>
> To: Jan Chaloupecky <chaljan@gmail.com>
> Date: Thu, 2 Aug 2012 14:04:36 +0200
> Content-Transfer-Encoding: 7bit
> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
> X-Mailer: Apple Mail (2.1278)
> 
> Hello,
> Jan



I initialize the message using:

>     NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_7102460239854714054" ofType:@"txt"];
>     if (filePath) {
>         testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>     }



The CTCoreMessage seems to be initialized since testMsg.to, testMsg.from 
and testMsg.subject return the correct values. Here is a screenshot of the
debugger 

http://cl.ly/IVy2


Then I send the message using CTSMTPConnection but the received message is
empty. No headers or content at all. Here is the data which are going on 
the wire where we can see that only the smtp envelope recipient and sender
are supplied:

http://cl.ly/IVum


What am I doing wrong?

regards,
Jan




CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-03 @ 06:45
Hi,
I'm trying to create a CTCoreMessage with a content of a .eml file without
success. The file contains the following message:

> Subject: MySubject
> Mime-Version: 1.0 (Apple Message framework v1278)
> Content-Type: text/plain; charset=us-ascii
> From: MySender <mysender@mydomain.com>
> To: Jan Chaloupecky <chaljan@gmail.com>
> Date: Thu, 2 Aug 2012 14:04:36 +0200
> Content-Transfer-Encoding: 7bit
> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
> X-Mailer: Apple Mail (2.1278)
> 
> Hello,
> Jan



I initialize the message using:

>     NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_7102460239854714054" ofType:@"txt"];
>     if (filePath) {
>         testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>     }



The CTCoreMessage seems to be initialized since testMsg.to, testMsg.from 
and testMsg.subject return the correct values. Here is a screenshot of the
debugger 

http://cl.ly/IVy2


Then I send the message using CTSMTPConnection but the received message is
empty. No headers or content at all. Here is the data which are going on 
the wire where we can see that only the smtp envelope recipient and sender
are supplied:

http://cl.ly/IVum


What am I doing wrong?

regards,
Jan

PS: I'm not sure if this email went through correctly so I resent it. 
Sorry for double post if it was sent twice



Re: CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-03 @ 08:10
ok, it looks like I have to call 

[testMsg body]

to render the text message body. But this leads me to another question. 
The message I want to create is actually neither text/plain nor text/html.
It's a S/MIME encrypted message which should look like this:


> Subject: MySubject
> MIME-Version: 1.0
> From: MySender <mysender@mydomain.com>
> To: Jan Chaloupecky <chaljan@gmail.com>
> Date: Thu, 2 Aug 2012 14:04:36 +0200
> X-Mailer: Apple Mail (2.1278)
> Content-Disposition: attachment; filename="smime.p7m"
> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
> Content-Transfer-Encoding: base64
> 
> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=


The question is how can I build a CTCoreMessage which will render like 
this? I do already have the s/mime body data:

> MIME-Version: 1.0
> Content-Disposition: attachment; filename="smime.p7m"
> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
> Content-Transfer-Encoding: base64
> 
> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=



cheers,
Jan



On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:

> Hi,
> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
> 
>> Subject: MySubject
>> Mime-Version: 1.0 (Apple Message framework v1278)
>> Content-Type: text/plain; charset=us-ascii
>> From: MySender <mysender@mydomain.com>
>> To: Jan Chaloupecky <chaljan@gmail.com>
>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>> Content-Transfer-Encoding: 7bit
>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>> X-Mailer: Apple Mail (2.1278)
>> 
>> Hello,
>> Jan
> 
> 
> 
> I initialize the message using:
> 
>>     NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_7102460239854714054" ofType:@"txt"];
>>     if (filePath) {
>>         testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>     }
> 
> 
> 
> The CTCoreMessage seems to be initialized since testMsg.to, testMsg.from
and testMsg.subject return the correct values. Here is a screenshot of the
debugger 
> 
> http://cl.ly/IVy2
> 
> 
> Then I send the message using CTSMTPConnection but the received message 
is empty. No headers or content at all. Here is the data which are going 
on the wire where we can see that only the smtp envelope recipient and 
sender are supplied:
> 
> http://cl.ly/IVum
> 
> 
> What am I doing wrong?
> 
> regards,
> Jan
> 
> PS: I'm not sure if this email went through correctly so I resent it. 
Sorry for double post if it was sent twice
> 
> 
> 
> 

Re: [mailcore] Re: CTCoreMessage initWithString usage

From:
Matt Ronge
Date:
2012-08-03 @ 13:14
Try calling [testMsg fetchBodyStructure] instead of [testMsg body], does 
that work?

Also, you may have to add an subclass of CTMIME_SinglePart to set the 
S/MIME content. Take a look at CTMIME_TextPart and in particular 
buildMIMEStruct. From there you'll have to add a method to CTCoreMessage 
like setBody: but uses your SMIME implementation instead. You MAY be able 
to avoid all this if fetchBodyStructure works, so try that first.
--
Matt Ronge
mronge@mronge.com
iOS Developer & Consultant
Central Atomics Inc.




On Aug 3, 2012, at 3:10 AM, Jan Chaloupecky <chaljan@gmail.com> wrote:

> ok, it looks like I have to call 
> 
> [testMsg body]
> 
> to render the text message body. But this leads me to another question. 
The message I want to create is actually neither text/plain nor text/html.
It's a S/MIME encrypted message which should look like this:
> 
> 
>> Subject: MySubject
>> MIME-Version: 1.0
>> From: MySender <mysender@mydomain.com>
>> To: Jan Chaloupecky <chaljan@gmail.com>
>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>> X-Mailer: Apple Mail (2.1278)
>> Content-Disposition: attachment; filename="smime.p7m"
>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>> Content-Transfer-Encoding: base64
>> 
>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k< /font>
>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>> AQcBMBoGCCqGSIb3DQMCMA 4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
> 
> 
> The question is how can I build a CTCoreMessage which will render like 
this? I do already have the s/mime body data:
> 
>> MIME-Version: 1.0
>> Content-Disposition: attachment; filename="smime.p7m"
>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>> Content-Transfer-Encoding: base64
>> 
>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>> +SVDt3q1O gHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
> 
> 
> 
> cheers,
> Jan
> 
> 
> 
> On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:
> 
>> Hi,
>> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
>> 
>>> Subject: MySubject
>>> Mime-Version: 1.0 (Apple Message framework v1278)
>>> Content-Type: text/plain; charset=us-ascii
>>> From: MySender <mysender@mydomain.com>
>>> To: Jan Chaloupecky <chaljan@gma il.com>
>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>> Content-Transfer-Encoding: 7bit
>>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>>> X-Mailer: Apple Mail (2.1278)
>>> 
>>> Hello,
>>> Jan
>> 
>> 
>> I initialize the message using:
>> 
>>>     NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_710246023 9854714054" ofType:@"txt"];
>>>     if (filePath) {
>>>         testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>>     }
>> 
>> 
>> The CTCoreMessage seems to be initialized since testMsg.to, 
testMsg.from and testMsg.subject return the correct values. Here is a 
screenshot of the debugger 
>> 
>> http://cl.ly/IVy2
>> 
>> 
>> Then I send the message using CTSMTPCon nection but the received 
message is empty. No headers or content at all. Here is the data which are
going on the wire where we can see that only the smtp envelope recipient 
and sender are supplied:
>> 
>> http://cl.ly/IVum
>> 
>> 
>> What am I doing wrong?
>> 
>> regards,
>> Jan
>> 
>> PS: I'm not sure if this email went through correctly so I resent it. 
Sorry for double post if it was sent twice
>> 
>> 
>> 
>> 
> 

Re: [mailcore] CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-06 @ 07:38
Hi Matt,
so I was experimenting with the CTCoreMessage#initWithFileAtPath to parse 
simple text mails and I'm not sure what this method is supposed to do.

Parsing a Content-Type:text/plain mail somehow works after calling 
[testMsg body]  but the headers are not set correctly. My input mime mail 
has e.g. a charset=ascii and the rendered MailCore msg has a UTF8 charset.

Parsing a Content-Type:text/html does not work at all. There is not body 
in the rendered MailCore msg. 

I send here a sample project with the different test cases.

http://cl.ly/IYnG

Am I doing something wrong?

regards,
Jan


On Aug 3, 2012, at 3:14 PM, Matt Ronge wrote:

> Try calling [testMsg fetchBodyStructure] instead of [testMsg body], does
that work?
> 
> Also, you may have to add an subclass of CTMIME_SinglePart to set the 
S/MIME content. Take a look at CTMIME_TextPart and in particular 
buildMIMEStruct. From there you'll have to add a method to CTCoreMessage 
like setBody: but uses your SMIME implementation instead. You MAY be able 
to avoid all this if fetchBodyStructure works, so try that first.
> --
> Matt Ronge
> mronge@mronge.com
> iOS Developer & Consultant
> Central Atomics Inc.
> 
> 
> 
> 
> On Aug 3, 2012, at 3:10 AM, Jan Chaloupecky <chaljan@gmail.com> wrote:
> 
>> ok, it looks like I have to call 
>> 
>> [testMsg body]
>> 
>> to render the text message body. But this leads me to another question.
The message I want to create is actually neither text/plain nor text/html.
It's a S/MIME encrypted message which should look like this:
>> 
>> 
>>> Subject: MySubject
>>> MIME-Version: 1.0
>>> From: MySender <mysender@mydomain.com>
>>> To: Jan Chaloupecky <chaljan@gmail.com>
>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>> X-Mailer: Apple Mail (2.1278)
>>> Content-Disposition: attachment; filename="smime.p7m"
>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>> Content-Transfer-Encoding: base64
>>> 
>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k< /font>
>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>> AQcBMBoGCCqGSIb3DQMCMA 4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>> 
>> 
>> The question is how can I build a CTCoreMessage which will render like 
this? I do already have the s/mime body data:
>> 
>>> MIME-Version: 1.0
>>> Content-Disposition: attachment; filename="smime.p7m"
>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>> Content-Transfer-Encoding: base64
>>> 
>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>> +SVDt3q1O gHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>> 
>> 
>> 
>> cheers,
>> Jan
>> 
>> 
>> 
>> On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:
>> 
>>> Hi,
>>> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
>>> 
>>>> Subject: MySubject
>>>> Mime-Version: 1.0 (Apple Message framework v1278)
>>>> Content-Type: text/plain; charset=us-ascii
>>>> From: MySender <mysender@mydomain.com>
>>>> To: Jan Chaloupecky <chaljan@gma il.com>
>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>> Content-Transfer-Encoding: 7bit
>>>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>>>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>>>> X-Mailer: Apple Mail (2.1278)
>>>> 
>>>> Hello,
>>>> Jan
>>> 
>>> 
>>> I initialize the message using:
>>> 
>>>>    NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_710246023 9854714054" ofType:@"txt"];
>>>>    if (filePath) {
>>>>        testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>>>    }
>>> 
>>> 
>>> The CTCoreMessage seems to be initialized since testMsg.to, 
testMsg.from and testMsg.subject return the correct values. Here is a 
screenshot of the debugger 
>>> 
>>> http://cl.ly/IVy2
>>> 
>>> 
>>> Then I send the message using CTSMTPCon nection but the received 
message is empty. No headers or content at all. Here is the data which are
going on the wire where we can see that only the smtp envelope recipient 
and sender are supplied:
>>> 
>>> http://cl.ly/IVum
>>> 
>>> 
>>> What am I doing wrong?
>>> 
>>> regards,
>>> Jan
>>> 
>>> PS: I'm not sure if this email went through correctly so I resent it. 
Sorry for double post if it was sent twice
>>> 
>>> 
>>> 
>>> 
>> 
> 

Re: [mailcore] CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-06 @ 07:54
As far as the text/html parsing is concerned, I think it is indeed not 
supported. The factory method creates all the time a CTMIME_TextPart


> + (CTMIME_SinglePart *)createMIMESinglePartWithMIMEStruct:(struct 
mailmime *)mime 
>                                                forMessage:(struct 
mailmessage *)message {
>     struct mailmime_type *aType = mime->mm_content_type->ct_type;
>     if (aType->tp_type != MAILMIME_TYPE_DISCRETE_TYPE) {
>         /* What do you do with a composite single part? */
>         return nil;
>     }
>     CTMIME_SinglePart *content = nil;
>     switch (aType->tp_data.tp_discrete_type->dt_type) {
>         case MAILMIME_DISCRETE_TYPE_TEXT:
>             content = [[CTMIME_TextPart alloc] initWithMIMEStruct:mime
>                                                        forMessage:message];
>             break;
> 
>         default:
>             content = [[CTMIME_SinglePart alloc] initWithMIMEStruct:mime
>                                                          forMessage:message];
>             break;
>     }
>     return [content autorelease];
> }




On Aug 6, 2012, at 9:38 AM, Jan Chaloupecky wrote:

> Hi Matt,
> so I was experimenting with the CTCoreMessage#initWithFileAtPath to 
parse simple text mails and I'm not sure what this method is supposed to 
do.
> 
> Parsing a Content-Type:text/plain mail somehow works after calling 
[testMsg body]  but the headers are not set correctly. My input mime mail 
has e.g. a charset=ascii and the rendered MailCore msg has a UTF8 charset.
> 
> Parsing a Content-Type:text/html does not work at all. There is not body
in the rendered MailCore msg. 
> 
> I send here a sample project with the different test cases.
> 
> http://cl.ly/IYnG
> 
> Am I doing something wrong?
> 
> regards,
> Jan
> 
> 
> On Aug 3, 2012, at 3:14 PM, Matt Ronge wrote:
> 
>> Try calling [testMsg fetchBodyStructure] instead of [testMsg body], 
does that work?
>> 
>> Also, you may have to add an subclass of CTMIME_SinglePart to set the 
S/MIME content. Take a look at CTMIME_TextPart and in particular 
buildMIMEStruct. From there you'll have to add a method to CTCoreMessage 
like setBody: but uses your SMIME implementation instead. You MAY be able 
to avoid all this if fetchBodyStructure works, so try that first.
>> --
>> Matt Ronge
>> mronge@mronge.com
>> iOS Developer & Consultant
>> Central Atomics Inc.
>> 
>> 
>> 
>> 
>> On Aug 3, 2012, at 3:10 AM, Jan Chaloupecky <chaljan@gmail.com> wrote:
>> 
>>> ok, it looks like I have to call 
>>> 
>>> [testMsg body]
>>> 
>>> to render the text message body. But this leads me to another 
question. The message I want to create is actually neither text/plain nor 
text/html. It's a S/MIME encrypted message which should look like this:
>>> 
>>> 
>>>> Subject: MySubject
>>>> MIME-Version: 1.0
>>>> From: MySender <mysender@mydomain.com>
>>>> To: Jan Chaloupecky <chaljan@gmail.com>
>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>> X-Mailer: Apple Mail (2.1278)
>>>> Content-Disposition: attachment; filename="smime.p7m"
>>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>>> Content-Transfer-Encoding: base64
>>>> 
>>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k< /font>
>>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>>> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>>> AQcBMBoGCCqGSIb3DQMCMA 4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>>> 
>>> 
>>> The question is how can I build a CTCoreMessage which will render like
this? I do already have the s/mime body data:
>>> 
>>>> MIME-Version: 1.0
>>>> Content-Disposition: attachment; filename="smime.p7m"
>>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>>> Content-Transfer-Encoding: base64
>>>> 
>>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
>>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>>> +SVDt3q1O gHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>>> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>>> 
>>> 
>>> 
>>> cheers,
>>> Jan
>>> 
>>> 
>>> 
>>> On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:
>>> 
>>>> Hi,
>>>> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
>>>> 
>>>>> Subject: MySubject
>>>>> Mime-Version: 1.0 (Apple Message framework v1278)
>>>>> Content-Type: text/plain; charset=us-ascii
>>>>> From: MySender <mysender@mydomain.com>
>>>>> To: Jan Chaloupecky <chaljan@gma il.com>
>>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>>> Content-Transfer-Encoding: 7bit
>>>>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>>>>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>>>>> X-Mailer: Apple Mail (2.1278)
>>>>> 
>>>>> Hello,
>>>>> Jan
>>>> 
>>>> 
>>>> I initialize the message using:
>>>> 
>>>>>    NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_710246023 9854714054" ofType:@"txt"];
>>>>>    if (filePath) {
>>>>>        testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>>>>    }
>>>> 
>>>> 
>>>> The CTCoreMessage seems to be initialized since testMsg.to, 
testMsg.from and testMsg.subject return the correct values. Here is a 
screenshot of the debugger 
>>>> 
>>>> http://cl.ly/IVy2
>>>> 
>>>> 
>>>> Then I send the message using CTSMTPCon nection but the received 
message is empty. No headers or content at all. Here is the data which are
going on the wire where we can see that only the smtp envelope recipient 
and sender are supplied:
>>>> 
>>>> http://cl.ly/IVum
>>>> 
>>>> 
>>>> What am I doing wrong?
>>>> 
>>>> regards,
>>>> Jan
>>>> 
>>>> PS: I'm not sure if this email went through correctly so I resent it.
Sorry for double post if it was sent twice
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> 
> 

Re: [mailcore] CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-13 @ 09:27
Hi,
so I'm still trying to figure out how to create a message part from 
existing data and add it to my core message as it is and send the message 
as it is.

I'm using this but it does not work:

CTCoreMessage *msg = [[CTCoreMessage alloc] init];
[msg setTo: ...];
[msg setFrom: …];



NSData *myPartData = … 
CTMIME_SinglePart *part = [CTMIME_SinglePart mimeSinglePartWithData: myPartData];

CTMIME_MessagePart *msgPart = [CTMIME_MessagePart 
mimeMessagePartWithContent:part];
msg.mime=msgPart;

// send here



The myPartData are the bytes of the part including all the part headers. 
So I just want to add this as the 1st body part of my ct message and send 
it. 

It should be a pretty simple task but I'm totally stuck.


cheers 




 




On Aug 3, 2012, at 3:14 PM, Matt Ronge wrote:

> Try calling [testMsg fetchBodyStructure] instead of [testMsg body], does
that work?
> 
> Also, you may have to add an subclass of CTMIME_SinglePart to set the 
S/MIME content. Take a look at CTMIME_TextPart and in particular 
buildMIMEStruct. From there you'll have to add a method to CTCoreMessage 
like setBody: but uses your SMIME implementation instead. You MAY be able 
to avoid all this if fetchBodyStructure works, so try that first.
> --
> Matt Ronge
> mronge@mronge.com
> iOS Developer & Consultant
> Central Atomics Inc.
> 
> 
> 
> 
> On Aug 3, 2012, at 3:10 AM, Jan Chaloupecky <chaljan@gmail.com> wrote:
> 
>> ok, it looks like I have to call 
>> 
>> [testMsg body]
>> 
>> to render the text message body. But this leads me to another question.
The message I want to create is actually neither text/plain nor text/html.
It's a S/MIME encrypted message which should look like this:
>> 
>> 
>>> Subject: MySubject
>>> MIME-Version: 1.0
>>> From: MySender <mysender@mydomain.com>
>>> To: Jan Chaloupecky <chaljan@gmail.com>
>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>> X-Mailer: Apple Mail (2.1278)
>>> Content-Disposition: attachment; filename="smime.p7m"
>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>> Content-Transfer-Encoding: base64
>>> 
>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k< /font>
>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>> AQcBMBoGCCqGSIb3DQMCMA 4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>> 
>> 
>> The question is how can I build a CTCoreMessage which will render like 
this? I do already have the s/mime body data:
>> 
>>> MIME-Version: 1.0
>>> Content-Disposition: attachment; filename="smime.p7m"
>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>> Content-Transfer-Encoding: base64
>>> 
>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>> +SVDt3q1O gHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>> 
>> 
>> 
>> cheers,
>> Jan
>> 
>> 
>> 
>> On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:
>> 
>>> Hi,
>>> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
>>> 
>>>> Subject: MySubject
>>>> Mime-Version: 1.0 (Apple Message framework v1278)
>>>> Content-Type: text/plain; charset=us-ascii
>>>> From: MySender <mysender@mydomain.com>
>>>> To: Jan Chaloupecky <chaljan@gma il.com>
>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>> Content-Transfer-Encoding: 7bit
>>>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>>>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>>>> X-Mailer: Apple Mail (2.1278)
>>>> 
>>>> Hello,
>>>> Jan
>>> 
>>> 
>>> I initialize the message using:
>>> 
>>>>    NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_710246023 9854714054" ofType:@"txt"];
>>>>    if (filePath) {
>>>>        testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>>>    }
>>> 
>>> 
>>> The CTCoreMessage seems to be initialized since testMsg.to, 
testMsg.from and testMsg.subject return the correct values. Here is a 
screenshot of the debugger 
>>> 
>>> http://cl.ly/IVy2
>>> 
>>> 
>>> Then I send the message using CTSMTPCon nection but the received 
message is empty. No headers or content at all. Here is the data which are
going on the wire where we can see that only the smtp envelope recipient 
and sender are supplied:
>>> 
>>> http://cl.ly/IVum
>>> 
>>> 
>>> What am I doing wrong?
>>> 
>>> regards,
>>> Jan
>>> 
>>> PS: I'm not sure if this email went through correctly so I resent it. 
Sorry for double post if it was sent twice
>>> 
>>> 
>>> 
>>> 
>> 
> 

Re: [mailcore] CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-13 @ 10:52
So now I tried using the CTMIMEFactory and passing mail mime structure 
that is parsed using directly libetpan. This seems to work better but the 
problem is that the body part has no content!


CTCoreMessage *msg = [[CTCoreMessage alloc] init];

[msg setTo: ...;
[msg setFrom: … ;


struct mailmime * mime;
size_t current_index = 0;

NSData *data = … ; // my part content 

// here I use LibEtPan to parse the part

int r = mailmime_parse(data.bytes, data.length, ¤t_index, &mime);
if (r == MAILIMF_NO_ERROR) {


       int col = 0;
       // debug dump: the part is CORRECTLY displayed here
       mailmime_write_file(stdout, &col, mime);
       CTMIME *part =  [CTMIMEFactory createMIMEWithMIMEStruct:mime 
forMessage:msg.messageStruct];
       msg.mime=part;

       // This displays only the part headers!
       NSLog(@"PART: %@", [part render]);

       [msg fetchBodyStructure];

       // This displays only the message + part headers!
       NSLog(@"MSG RENDER \n%@", [msg render]);

       // This is empty! No body part content
       NSLog(@"MSG BODY \n%@", [msg body]);

       [self sendMessage:msg];

}






On Aug 13, 2012, at 11:27 AM, Jan Chaloupecky wrote:

> Hi,
> so I'm still trying to figure out how to create a message part from 
existing data and add it to my core message as it is and send the message 
as it is.
> 
> I'm using this but it does not work:
> 
> CTCoreMessage *msg = [[CTCoreMessage alloc] init];
> [msg setTo: ...];
> [msg setFrom: …];
> 
> 
> 
> NSData *myPartData = … 
> CTMIME_SinglePart *part = [CTMIME_SinglePart mimeSinglePartWithData: 
myPartData];
> 
> CTMIME_MessagePart *msgPart = [CTMIME_MessagePart 
mimeMessagePartWithContent:part];
> msg.mime=msgPart;
> 
> // send here
> 
> 
> 
> The myPartData are the bytes of the part including all the part headers.
So I just want to add this as the 1st body part of my ct message and send 
it. 
> 
> It should be a pretty simple task but I'm totally stuck.
> 
> 
> cheers 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> On Aug 3, 2012, at 3:14 PM, Matt Ronge wrote:
> 
>> Try calling [testMsg fetchBodyStructure] instead of [testMsg body], 
does that work?
>> 
>> Also, you may have to add an subclass of CTMIME_SinglePart to set the 
S/MIME content. Take a look at CTMIME_TextPart and in particular 
buildMIMEStruct. From there you'll have to add a method to CTCoreMessage 
like setBody: but uses your SMIME implementation instead. You MAY be able 
to avoid all this if fetchBodyStructure works, so try that first.
>> --
>> Matt Ronge
>> mronge@mronge.com
>> iOS Developer & Consultant
>> Central Atomics Inc.
>> 
>> 
>> 
>> 
>> On Aug 3, 2012, at 3:10 AM, Jan Chaloupecky <chaljan@gmail.com> wrote:
>> 
>>> ok, it looks like I have to call 
>>> 
>>> [testMsg body]
>>> 
>>> to render the text message body. But this leads me to another 
question. The message I want to create is actually neither text/plain nor 
text/html. It's a S/MIME encrypted message which should look like this:
>>> 
>>> 
>>>> Subject: MySubject
>>>> MIME-Version: 1.0
>>>> From: MySender <mysender@mydomain.com>
>>>> To: Jan Chaloupecky <chaljan@gmail.com>
>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>> X-Mailer: Apple Mail (2.1278)
>>>> Content-Disposition: attachment; filename="smime.p7m"
>>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>>> Content-Transfer-Encoding: base64
>>>> 
>>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k< /font>
>>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>>> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>>> AQcBMBoGCCqGSIb3DQMCMA 4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>>> 
>>> 
>>> The question is how can I build a CTCoreMessage which will render like
this? I do already have the s/mime body data:
>>> 
>>>> MIME-Version: 1.0
>>>> Content-Disposition: attachment; filename="smime.p7m"
>>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>>> Content-Transfer-Encoding: base64
>>>> 
>>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
>>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>>> +SVDt3q1O gHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>>> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>>> 
>>> 
>>> 
>>> cheers,
>>> Jan
>>> 
>>> 
>>> 
>>> On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:
>>> 
>>>> Hi,
>>>> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
>>>> 
>>>>> Subject: MySubject
>>>>> Mime-Version: 1.0 (Apple Message framework v1278)
>>>>> Content-Type: text/plain; charset=us-ascii
>>>>> From: MySender <mysender@mydomain.com>
>>>>> To: Jan Chaloupecky <chaljan@gma il.com>
>>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>>> Content-Transfer-Encoding: 7bit
>>>>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>>>>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>>>>> X-Mailer: Apple Mail (2.1278)
>>>>> 
>>>>> Hello,
>>>>> Jan
>>>> 
>>>> 
>>>> I initialize the message using:
>>>> 
>>>>>    NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_710246023 9854714054" ofType:@"txt"];
>>>>>    if (filePath) {
>>>>>        testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>>>>    }
>>>> 
>>>> 
>>>> The CTCoreMessage seems to be initialized since testMsg.to, 
testMsg.from and testMsg.subject return the correct values. Here is a 
screenshot of the debugger 
>>>> 
>>>> http://cl.ly/IVy2
>>>> 
>>>> 
>>>> Then I send the message using CTSMTPCon nection but the received 
message is empty. No headers or content at all. Here is the data which are
going on the wire where we can see that only the smtp envelope recipient 
and sender are supplied:
>>>> 
>>>> http://cl.ly/IVum
>>>> 
>>>> 
>>>> What am I doing wrong?
>>>> 
>>>> regards,
>>>> Jan
>>>> 
>>>> PS: I'm not sure if this email went through correctly so I resent it.
Sorry for double post if it was sent twice
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> 
> 

Re: [mailcore] CTCoreMessage initWithString usage

From:
Jan Chaloupecky
Date:
2012-08-03 @ 13:52
I'm now trying to set the s/mime part to the message. This works partially:


>     CTCoreMessage *msg = [[CTCoreMessage alloc] init];
>     
>     CTMIME_SinglePart *part = [CTMIME_SinglePart 
mimeSinglePartWithData:[self encryptedContent]]; 
> 
>     // I have to set those otherwise BAD EXEC in -[CTMIME_SinglePart 
buildMIMEStruct]  ([part contentType] is nil
>     part.contentType = @"application/x-pkcs7-mime; 
smime-type=enveloped-data; name=\"smime.p7m\"";
>     part.filename = @"smime.p7m";
> 
>     // nil if not set manually!
>     NSLog(@"Part ContentType: %@", [part contentType]);
> 
> 
>     CTMIME_MessagePart *msgPart = [CTMIME_MessagePart 
mimeMessagePartWithContent:part];
>     msg.mime=msgPart;
> 
>     NSLog(@"%@", [msg render]);




The [self encryptedContent] is the entire S/MIME part (including headers 
as I posted it earlier in this mail). The problem with this is that 
MailCore will re-encode in base 64 the content that is already in base 64.
So I guess I will have to
- remove the headers from my smime part
- get only the base64 encoded body and decoded
- pass it to [CTMIME_SinglePart mimeSinglePartWithData]






On Aug 3, 2012, at 3:14 PM, Matt Ronge wrote:

> Try calling [testMsg fetchBodyStructure] instead of [testMsg body], does
that work?
> 
> Also, you may have to add an subclass of CTMIME_SinglePart to set the 
S/MIME content. Take a look at CTMIME_TextPart and in particular 
buildMIMEStruct. From there you'll have to add a method to CTCoreMessage 
like setBody: but uses your SMIME implementation instead. You MAY be able 
to avoid all this if fetchBodyStructure works, so try that first.
> --
> Matt Ronge
> mronge@mronge.com
> iOS Developer & Consultant
> Central Atomics Inc.
> 
> 
> 
> 
> On Aug 3, 2012, at 3:10 AM, Jan Chaloupecky <chaljan@gmail.com> wrote:
> 
>> ok, it looks like I have to call 
>> 
>> [testMsg body]
>> 
>> to render the text message body. But this leads me to another question.
The message I want to create is actually neither text/plain nor text/html.
It's a S/MIME encrypted message which should look like this:
>> 
>> 
>>> Subject: MySubject
>>> MIME-Version: 1.0
>>> From: MySender <mysender@mydomain.com>
>>> To: Jan Chaloupecky <chaljan@gmail.com>
>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>> X-Mailer: Apple Mail (2.1278)
>>> Content-Disposition: attachment; filename="smime.p7m"
>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>> Content-Transfer-Encoding: base64
>>> 
>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k< /font>
>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>> +SVDt3q1OgHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>> AQcBMBoGCCqGSIb3DQMCMA 4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>> 
>> 
>> The question is how can I build a CTCoreMessage which will render like 
this? I do already have the s/mime body data:
>> 
>>> MIME-Version: 1.0
>>> Content-Disposition: attachment; filename="smime.p7m"
>>> Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; 
name="smime.p7m"
>>> Content-Transfer-Encoding: base64
>>> 
>>> MIIChgYJKoZIhvcNAQcDoIICdzCCAnMCAQAxggG3MIIBswIBADCBmjCBlDELMAkG
>>> A1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGluMRAwDgYD
>>> VQQKDAdFbmQyRW5kMRAwDgYDVQQLDAdFbmQyRW5kMRgwFgYDVQQDDA9FbmQyRW5k
>>> IFJvb3QgQ0ExJTAjBgkqhkiG9w0BCQEWFng1MDktY2FAemVydGlmaWNvbi5jb20C
>>> AQIwDQYJKoZIhvcNAQEBBQAEggEASWyCf8cTLfz3azqzXgC/YcViD2HyaS3YpUH5
>>> S6ozXjShKN08rAkjLolpNsefInhaRfRbsfShf+6VK/JYHc25Ww/iGsGeWGLpyuZA
>>> +SVDt3q1O gHG2Jj9qjMKf6pC6hNr4cNnZgqzdcyyW3fUpM1Yogj8p6oa9iUYFvEL
>>> 5Jdzrz2U2Ncj5efWj2PcPpowDQCyjgcdbG7hbrbMucnHZ4RQHZkVuTjRPswW208L
>>> wl3FEJOE7KNw0LGCYK7ESiV983kMT366Afl76AdnQC6KfIt/L3a6uQh+6OIqPr61
>>> OfEgdamlt8ekdKgY1/Izt97959bfKzNFjIl+47bCfXBUM8wyUTCBsgYJKoZIhvcN
>>> AQcBMBoGCCqGSIb3DQMCMA4CAgCgBAg67LCs4fVvdYCBiILOErA7k97Mkel+nLk2
>>> lcOMiUmjxAseFFfKsCzE/tO45tHVVMi84SNrNtHcf8XSspGCXMff6gqzmSOzgJZX
>>> PgTxmB8cEgPbDVrh9qaKe7g+00oX1pcfEfiyHl+yFtFVJyNSbcLE1Ohy6JNhRd3Q
>>> TQ9nQ8K4BlTbcbPIbK/IBzbXj9UNMBKIevQ=
>> 
>> 
>> 
>> cheers,
>> Jan
>> 
>> 
>> 
>> On Aug 3, 2012, at 8:45 AM, Jan Chaloupecky wrote:
>> 
>>> Hi,
>>> I'm trying to create a CTCoreMessage with a content of a .eml file 
without success. The file contains the following message:
>>> 
>>>> Subject: MySubject
>>>> Mime-Version: 1.0 (Apple Message framework v1278)
>>>> Content-Type: text/plain; charset=us-ascii
>>>> From: MySender <mysender@mydomain.com>
>>>> To: Jan Chaloupecky <chaljan@gma il.com>
>>>> Date: Thu, 2 Aug 2012 14:04:36 +0200
>>>> Content-Transfer-Encoding: 7bit
>>>> Resent-Date: Thu, 2 Aug 2012 14:06:41 +0200
>>>> Message-Id: <864B54F5-BA6A-4FA6-B032-C838B3C6A219@bonelabs.com>
>>>> X-Mailer: Apple Mail (2.1278)
>>>> 
>>>> Hello,
>>>> Jan
>>> 
>>> 
>>> I initialize the message using:
>>> 
>>>>    NSString *filePath = [[NSBundle mainBundle] 
pathForResource:@"gateway_in_710246023 9854714054" ofType:@"txt"];
>>>>    if (filePath) {
>>>>        testMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
>>>>    }
>>> 
>>> 
>>> The CTCoreMessage seems to be initialized since testMsg.to, 
testMsg.from and testMsg.subject return the correct values. Here is a 
screenshot of the debugger 
>>> 
>>> http://cl.ly/IVy2
>>> 
>>> 
>>> Then I send the message using CTSMTPCon nection but the received 
message is empty. No headers or content at all. Here is the data which are
going on the wire where we can see that only the smtp envelope recipient 
and sender are supplied:
>>> 
>>> http://cl.ly/IVum
>>> 
>>> 
>>> What am I doing wrong?
>>> 
>>> regards,
>>> Jan
>>> 
>>> PS: I'm not sure if this email went through correctly so I resent it. 
Sorry for double post if it was sent twice
>>> 
>>> 
>>> 
>>> 
>> 
>