Adding Text File Attachments

Discussion of the EDMessage and EDCommon frameworks.

Adding Text File Attachments

Postby OtterSoftware » 20 Apr 2010, 02:42

I'm trying to use the EDMessage framework to send an email with log files attached to it. The log files are text files and rather than adding them as attachments the contents of the text files are being included in the message's body. Is there a simple way around this?

Thank you for the frameworks too, the effort you have put into them is very much appreciated.
OtterSoftware
 
Posts: 5
Joined: 20 Apr 2010, 02:39
Location: Somerset, England

Re: Adding Text File Attachments

Postby erik » 23 Apr 2010, 01:45

How exactly do you attach the text files? And what is the resulting mime type for the text attachement?
erik
 
Posts: 90
Joined: 10 Oct 2009, 15:22
Location: Hamburg, Germany

Re: Adding Text File Attachments

Postby OtterSoftware » 25 May 2010, 16:06

Hi Erik and apologies for the long delay in replying.

You can see a more complete example of this in the attachment I added to my other post at http://www.mulle-kybernetik.com/forum/viewtopic.php?f=5&t=59&p=101#p79 but the relevant code is:

NSString *attachmentPath = [[NSBundle mainBundle] pathForResource:@"textfile" ofType:@"txt"];
NSData *attachmentData = [NSData dataWithContentsOfFile:attachmentPath];
NSArray *attachments = [NSArray arrayWithObject:[EDObjectPair pairWithObjects:attachmentData:[attachmentPath lastPathComponent]]];

In Apple's Mail application the contents of the text file is simply inserted into the body of the message and I think that Google Mail shows the same thing as does my mail provider's webmail interface but that at least shows that there is an attachment (although you can't see it once you read the message.

The relevant headers from the email are:
Content-Type: multipart/mixed; boundary=EDMessagePart-12747952670
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0 (EDMessage Framework v1.1)

The (chopped) raw source is:
Content-Type: multipart/mixed; boundary=EDMessagePart-12747952670
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0 (EDMessage Framework v1.1)

This is a MIME encoded message.

--EDMessagePart-12747952670
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

An example message body
--EDMessagePart-12747952670
Content-Type: text/plain; name=textfile.txt
Content-Transfer-Encoding: base64

VGhpcyBpcyBhbiBleGFtcGxlIHRleHQgZmlsZS4=

--EDMessagePart-12747952670--
OtterSoftware
 
Posts: 5
Joined: 20 Apr 2010, 02:39
Location: Somerset, England


Return to ED Frameworks



cron