Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-10-2009, 06:27 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 45
moonraker928 is on a distinguished road
Default sending attachments to email from iphone app

is there a way to add attachments (esp, images)? I know there wasn't before, but do the current Mail APIs support this feature?
moonraker928 is offline   Reply With Quote
Old 01-10-2009, 06:47 PM   #2 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
RickMaddy will become famous soon enough
Default

The SDK does not allow email attachments as of SDK 2.2. I wish it did.
RickMaddy is offline   Reply With Quote
Old 01-10-2009, 09:20 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

I send emails with attachments from my app. For that I use the SKSMTP and libz/minizip packages.

Last edited by lbendlin; 01-10-2009 at 09:26 PM.
lbendlin is offline   Reply With Quote
Old 01-11-2009, 12:17 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 243
noobAppDeveloper is on a distinguished road
Default

Quote:
Originally Posted by lbendlin View Post
I send emails with attachments from my app. For that I use the SKSMTP and libz/minizip packages.
Could you give some more details? I'd love to know how as well.
noobAppDeveloper is offline   Reply With Quote
Old 01-11-2009, 11:10 AM   #5 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default

skpsmtpmessage - Google Code
tkilmer is offline   Reply With Quote
Old 01-11-2009, 01:15 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

Look at thread 7615 for the zipping. I can't paste the link here because the jesusfone is too stupid for a simple cut-n-paste.
lbendlin is offline   Reply With Quote
Old 01-11-2009, 01:30 PM   #7 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
beachdog is on a distinguished road
Default

By the way, in playing around with sksmtp I found a bug if you use it with TLS authentication to a mail server that is using self-signed certificates. The code attempts to handle this by setting the relevant stream property (kCFStreamSSLValidatesCertificateChain); however, it seems that this property is ignored unless it is called AFTER setting the stream security level to TLSv1.
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 01-11-2009, 01:31 PM   #8 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default

There are a lot of issues with it. I found a couple myself. It is a great start though.
tkilmer is offline   Reply With Quote
Old 01-14-2009, 10:26 AM   #9 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

In the sample code for the skpsmtp, I'm having trouble following the attachment process:

What do I change the content type to if I want to attach an image or anything besides texzt
Right now its
Code:
text/directory/\r\n\t-unix-mode=0644;\r\n\t\name=\"anImage.png\"", kSKPSMTPPartContentTypeKey, ...
smithdale87 is offline   Reply With Quote
Old 01-14-2009, 10:29 AM   #10 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 45
moonraker928 is on a distinguished road
Default

smithdale87, are you getting skpsmpt to work on your app with sending plain text emails??
moonraker928 is offline   Reply With Quote
Old 01-14-2009, 10:30 AM   #11 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

yup
smithdale87 is offline   Reply With Quote
Old 01-14-2009, 10:37 AM   #12 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Alright got it working!

Here's what I needed to know about the content-type, which you need to change depending on what filetype you're sending:

Quote:
image, audio, video and application (for example, image/jpg, audio/mp3, video/mp4, and application/msword and so on)
So if I want to send an png image, I'll change it to
Code:
image/png\r\n\t-unix-mode=0644;\r\n\t\name=\"anImage.png\"", kSKPSMTPPartContentTypeKey, ...
smithdale87 is offline   Reply With Quote
Old 01-14-2009, 10:38 AM   #13 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 45
moonraker928 is on a distinguished road
Default

so i have included the following files:

Base64Transcoder.h/m
NSData+Base64Additions.h
NSStream+SKPSMTPExtensions.h/m
SKPSMTPMessage.h/m

i have also built the library, libsmtpmessage.a in my app frameworks.

i am getting a duplicate symbol linker error when i build my app. it is in regards to the duplicate building of SKPSMTPMessage and NSStream+SKPSMTPExtensions since it is found both in the library and the individual .h files. however, if i remove the .h files or the library, the app doesn't work.

what i want to know from you is which files you included/did u face any errors during building/how did u fix them?

thanks a bunch!
moonraker928 is offline   Reply With Quote
Old 01-14-2009, 11:08 AM   #14 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

to begin with, I just ran the project that was included with the download. It all worked fine.


On a side note: I'm now having trouble including html links in the body of my message. Does anyone have a clue how do this?
smithdale87 is offline   Reply With Quote
Old 01-14-2009, 08:29 PM   #15 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

Quote:
Originally Posted by moonraker928 View Post
so i have included the following files:

Base64Transcoder.h/m
NSData+Base64Additions.h
NSStream+SKPSMTPExtensions.h/m
SKPSMTPMessage.h/m

i have also built the library, libsmtpmessage.a in my app frameworks.
You only need one of them - either including the whole source into your project, or building and using the library.

for a binary file (aka attachment) you can use "application/octet-stream"

Last edited by lbendlin; 01-14-2009 at 08:32 PM.
lbendlin is offline   Reply With Quote
Old 01-15-2009, 05:01 AM   #16 (permalink)
iPhone Developer
 
Narender Mudgal's Avatar
 
Join Date: Dec 2008
Location: India
Age: 28
Posts: 156
Narender Mudgal is on a distinguished road
Send a message via MSN to Narender Mudgal Send a message via Skype™ to Narender Mudgal
Default SMS

Hi there,
does anyone of you know
how to send sms through our own application.
i tried with some classes of iSms application
but it stuck somewhere in device.c file
where it is trying to open "dev/tty.debug " file
and getting terminated
is there any other way ?(except openURL because we cant send message body). thanks
Narender Mudgal is offline   Reply With Quote
Old 01-15-2009, 08:47 AM   #17 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Quote:
Originally Posted by Narender Mudgal View Post
Hi there,
does anyone of you know
how to send sms through our own application.
i tried with some classes of iSms application
but it stuck somewhere in device.c file
where it is trying to open "dev/tty.debug " file
and getting terminated
is there any other way ?(except openURL because we cant send message body). thanks
Don't hijack threads.

On a side note, has anyone been able to successfully get urls in the body of your email message when using sksmtp? When I try, the entire body becomes blank.
smithdale87 is offline   Reply With Quote
Old 01-15-2009, 10:54 AM   #18 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 45
moonraker928 is on a distinguished road
Default

i built the library and updated the linker flags in the app properties. then i just initialized an SKPSMTPMessage object by saying:

SKPSMTPMessage *test = [[SKPSMTPMessage alloc] init];

but i am getting an error taht this symbol is not defined and can't be foun anywhere. since i dont have the m/h files beacuse I am building the library, how do i resolve this?
moonraker928 is offline   Reply With Quote
Old 01-15-2009, 10:57 AM   #19 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

you need to include the header files
smithdale87 is offline   Reply With Quote
Old 01-15-2009, 06:44 PM   #20 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

When I send an email using skpsmtp, the recipient sees the sender as the username of the authentication credentials for the relay server. IIs there anyway to send the mail directly instead of relaying? Or how would I show the correct sender in the relay?
smithdale87 is offline   Reply With Quote
Old 01-15-2009, 07:23 PM   #21 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

Do you use

SKPSMTPMessage *trackMsg = [[SKPSMTPMessage alloc] init];
trackMsg.fromEmail = @"me@mydomain.com";
trackMsg.toEmail = email;
trackMsg.login = @"user";
trackMsg.pass = @"password";

?
lbendlin is offline   Reply With Quote
Old 01-15-2009, 07:58 PM   #22 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

just answered my own question
Code:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'send requires relayHost'
smithdale87 is offline   Reply With Quote
Old 01-19-2009, 09:21 PM   #23 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Just figured out how to send url links in the body using the skcpsmtp sender.

You have to set the "plainPart" to use "text/html" instead of "text/plain";
smithdale87 is offline   Reply With Quote
Old 02-04-2009, 09:38 PM   #24 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 298
javid.alimohideen is an unknown quantity at this point
Default

Can someone help me as how to use the library to send a jpg image as attachments. I am using the following code to send an email with attachments. The email is sent with an attachment, but when I tried opening it nothing shows up

Code:
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"image/jpg\r\n\t-unix-mode=0644;\r\n\t\name=\"liberty.jpg\"", kSKPSMTPPartContentTypeKey,
                             @"attachment;\r\n\tfilename=\"liberty.jpg\"",kSKPSMTPPartContentDispositionKey,[vcfData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
Thanks for any help,
Javid
javid.alimohideen is offline   Reply With Quote
Old 02-04-2009, 10:10 PM   #25 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Quote:
Originally Posted by javid.alimohideen View Post
Can someone help me as how to use the library to send a jpg image as attachments. I am using the following code to send an email with attachments. The email is sent with an attachment, but when I tried opening it nothing shows up

Code:
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"image/jpg\r\n\t-unix-mode=0644;\r\n\t\name=\"liberty.jpg\"", kSKPSMTPPartContentTypeKey,
                             @"attachment;\r\n\tfilename=\"liberty.jpg\"",kSKPSMTPPartContentDispositionKey,[vcfData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
Thanks for any help,
Javid
I don't see anywhere that you are including an NSData object with the image's data
smithdale87 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 407
16 members and 391 guests
7twenty7, Eclectic, eski, EvilElf, fiftysixty, HemiMG, iOS.Lover, JackReidy, jarv, Pudding, sacha1996, teebee74, tim0504, UMAD, VinceYuan, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,905
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0