gdaiss / skpsmtpmessage

Automatically exported from code.google.com/p/skpsmtpmessage
0 stars 0 forks source link

unable to send a .png file as attachment. #32

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I was able to send the .vcf file as attachment, but when I try to send a
.png file, the attachment is not proper. The image at the receiver is seen
as 1k file with a '?'. I have added an image.png to my resources and am
trying to attach it.

What version of the product are you using? On what operating system?
iPhone

Please provide any additional information below.
File Size: 4-12 KB
My Source:
    testMsg.delegate = self;

    NSDictionary *plainPart = [NSDictionary
dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
                 @"[File] Uploaded
Picture",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,n
il];

    NSString *vcfPath = [[NSBundle mainBundle] pathForResource:@"image"
ofType:@"png"];
    NSData *vcfData = [NSData dataWithContentsOfFile:vcfPath];

    NSDictionary *vcfPart = [NSDictionary
dictionaryWithObjectsAndKeys:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=
\"image.png\"",kSKPSMTPPartContentTypeKey,

@"attachment;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey,[vc
fData
encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransfe
rEncodingKey,nil];

    testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil];

    [testMsg send];

Please find enclosed the image I see at receiver.

Thanks for help.
Svaths

Original issue reported on code.google.com by ahr.srivaths on 21 Apr 2009 at 11:08

Attachments:

GoogleCodeExporter commented 8 years ago
may be text/directory  replacing  image/png

Original comment by LeshikM...@gmail.com on 22 Apr 2009 at 3:53

GoogleCodeExporter commented 8 years ago
So, this works for me (with the image/png change) on the simulator, but it 
fails on
the device.

Any suggestions?  Has anyone gotten image (or audio, my real need) attachments 
to work?

Thanks
Ryan

Original comment by ryan.stu...@gmail.com on 16 Aug 2009 at 8:58

GoogleCodeExporter commented 8 years ago
Any luck?

If so, please email me at: noam.habot@gmail.com

Thanks!

Original comment by noam.ha...@gmail.com on 19 Aug 2009 at 5:09

GoogleCodeExporter commented 8 years ago
Try this for inline pictures.

NSString *image_path = [[NSBundle mainBundle] pathForResource:@"Icon" 
ofType:@"png"];
    NSData *image_data = [NSData dataWithContentsOfFile:image_path];        
    NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys:
                                    @"inline;\r\n\tfilename=\"Icon.png\"",kSKPSMTPPartContentDispositionKey,
                                    @"base64",kSKPSMTPPartContentTransferEncodingKey,
                                    @"image/png;\r\n\tname=Icon.png;\r\n\tx-unix-
mode=0666",kSKPSMTPPartContentTypeKey,
                                    [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey,
                                    nil];

testMsg.parts = [NSArray arrayWithObjects:plainPart,image_part,nil];

    [testMsg send];

Original comment by bull...@gmail.com on 11 Sep 2009 at 3:17

GoogleCodeExporter commented 8 years ago
Thanks  bullale@gmail.com, this worked for me.

Original comment by cbinge...@googlemail.com on 16 Nov 2012 at 10:52

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
@bullale@gmail.com It's wokring fine on simulator, but doesn't work on device.

Original comment by dinutest...@gmail.com on 16 Aug 2013 at 5:55