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-02-2012, 08:18 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: texas
Posts: 49
raptor85 is on a distinguished road
Default how to send email from an app

i am creating an app when a user clicks contactUS button a UIAlertview will appear where it consists of name , email textfield , when user clicks send UIButton , i should get an email saying user wants to contact me and user should receive a email saying thank you for the email . I want to know how to do it ,any help would be helpful .
raptor85 is offline   Reply With Quote
Old 01-02-2012, 09:11 AM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by raptor85 View Post
i am creating an app when a user clicks contactUS button a UIAlertview will appear where it consists of name , email textfield , when user clicks send UIButton , i should get an email saying user wants to contact me and user should receive a email saying thank you for the email . I want to know how to do it ,any help would be helpful .
If you want to send email in your application without writing a ton of code, the only solution I'm aware of is Apple's MFMailComposeViewController class. You pass it a from, subject, and body, as HTML strings, and it displays a compose mail form to the user. The user then clicks send and the mail is sent out.

I don't know of a way to send email without displaying an Apple mail form to the user.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-02-2012, 09:47 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: texas
Posts: 49
raptor85 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
If you want to send email in your application without writing a ton of code, the only solution I'm aware of is Apple's MFMailComposeViewController class. You pass it a from, subject, and body, as HTML strings, and it displays a compose mail form to the user. The user then clicks send and the mail is sent out.

I don't know of a way to send email without displaying an Apple mail form to the user.
is this MFMailCompseViewController class you are talking about
Loading…

but i want two emails to be send with different body and subject ..the user will get confirmation email and whereas i get his name ,email info so that i could contact him
raptor85 is offline   Reply With Quote
Old 01-02-2012, 10:02 AM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by raptor85 View Post
is this MFMailCompseViewController class you are talking about
Loading…

but i want two emails to be send with different body and subject ..the user will get confirmation email and whereas i get his name ,email info so that i could contact him

That sentence doesn't make much sense. Can you state what you want to do in clear, coherent sentences?

If you want to send an email to multiple addresses, that's easy.

If you want to send two different emails, you have to display two different compose mail windows. No way around it that I know of if you want to use Apple's frameworks. Otherwise you have a massive amount of code to write to do your own mail handling, or link to a server that does the work for you.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-02-2012, 10:04 AM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by raptor85 View Post
i am creating an app when a user clicks contactUS button a UIAlertview will appear where it consists of name , email textfield , when user clicks send UIButton , i should get an email saying user wants to contact me and user should receive a email saying thank you for the email . I want to know how to do it ,any help would be helpful .
The "thank you for the email" email should come from you, once you receive it. Don't send that locally, it would imply that you got it when you didn't. Plus, if you send email from the user's device, it would be sent from their email address, which you don't want.

You can set up the Apple mail client to auto-reply to emails. That's the zero-cost way to do it.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-02-2012, 10:12 AM   #6 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: texas
Posts: 49
raptor85 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
The "thank you for the email" email should come from you, once you receive it. Don't send that locally, it would imply that you got it when you didn't. Plus, if you send email from the user's device, it would be sent from their email address, which you don't want.

You can set up the Apple mail client to auto-reply to emails. That's the zero-cost way to do it.
how to set up auto reply to emails ? where should i implement it ? can u help me on that ..
raptor85 is offline   Reply With Quote
Old 01-02-2012, 01:02 PM   #7 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by raptor85 View Post
how to set up auto reply to emails ? where should i implement it ? can u help me on that ..


Go into the Apple mail application. Go to preferences. Click on rules. Create a new rule. Set it up to match on the subject/body of the message you send. (Make sure your app tells users not to change the mail subject, or create a mailbox that is only used for these mails.)

In the "Perform the following action" popup, select "Reply to message" and configure as desired.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-02-2012, 06:46 PM   #8 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: michigan
Posts: 197
michelle is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Go into the Apple mail application. Go to preferences. Click on rules. Create a new rule. Set it up to match on the subject/body of the message you send. (Make sure your app tells users not to change the mail subject, or create a mailbox that is only used for these mails.)

In the "Perform the following action" popup, select "Reply to message" and configure as desired.
If you asking how to send email from within your app and select sender and recipient its very simple.

Something like this

- (void) sendEmailToNSString *) toStr
withSubjectNSString *) subjectStr
withBodyNSString *) bodyStr {

NSString *emailString =
[[NSString alloc]
initWithFormat:@"mailto:?to=%@&subject=%@&body=%@" ,
[toStr
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding],
[subjectStr
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding],
[bodyStr
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailString]];
[emailString release];
}

-(IBAction) btnSend: (id) sender{
[self sendEmailTo:to.text withSubject:subject.text withBody:body.text];
}
__________________
Help us build great applications or let us make your applications exceptional. find us on Facebook
michelle is offline   Reply With Quote
Old 01-02-2012, 10:07 PM   #9 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by michelle View Post
If you asking how to send email from within your app and select sender and recipient its very simple.

Something like this

- (void) sendEmailToNSString *) toStr
withSubjectNSString *) subjectStr
withBodyNSString *) bodyStr {

NSString *emailString =
[[NSString alloc]
initWithFormat:@"mailto:?to=%@&subject=%@&body=%@" ,
[toStr
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding],
[subjectStr
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding],
[bodyStr
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailString]];
[emailString release];
}

-(IBAction) btnSend: (id) sender{
[self sendEmailTo:to.text withSubject:subject.text withBody:body.text];
}
Won't that code launch the mail client and display the mail you've composed, rather than sending the email from within the app?
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-02-2012, 11:44 PM   #10 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: texas
Posts: 49
raptor85 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Won't that code launch the mail client and display the mail you've composed, rather than sending the email from within the app?
i downloaded the apple mail application code, i tried to send a message to my email ,i havent received it ..does the app work only when it is loaded on the device or should i do something else like network check

I want to change few things in code where i'll be adding name textfield,email id textfield ,so when the user sends me email ,in the email his name and his email id should be displayed ,can u help me in these two points

Last edited by raptor85; 01-03-2012 at 02:12 AM. Reason: changes
raptor85 is offline   Reply With Quote
Old 01-03-2012, 07:46 AM   #11 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by raptor85 View Post
i downloaded the apple mail application code, i tried to send a message to my email ,i havent received it ..does the app work only when it is loaded on the device or should i do something else like network check

I want to change few things in code where i'll be adding name textfield,email id textfield ,so when the user sends me email ,in the email his name and his email id should be displayed ,can u help me in these two points
Yes, I believe it only works on the device, not the simulator.

I don't know what you mean by "i downloaded the apple mail application code". What code?

Take a look at the MFMailComposeViewController class I suggested at first. That's what you need to do.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-03-2012, 08:56 PM   #12 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: texas
Posts: 49
raptor85 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Yes, I believe it only works on the device, not the simulator.

I don't know what you mean by "i downloaded the apple mail application code". What code?

Take a look at the MFMailComposeViewController class I suggested at first. That's what you need to do.
i looked at MFMailComposeViewController class , it was available for download ,i tried to run it and the email didnt go through
raptor85 is offline   Reply With Quote
Old 01-03-2012, 09:16 PM   #13 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by raptor85 View Post
i looked at MFMailComposeViewController class , it was available for download ,i tried to run it and the email didnt go through
The MFMailComposeViewController class is built into the SDK. There's no downloading it. You just use it in your project.

You can't use it from the simulator. You have to run it on the device. It works perfectly. That is how you should send email from your application. Really, truly.

If it doesn't work, you need to fix your code.

We have 3 apps in the app store that all use that class to send email, and they support iOS 3.1 and later. (Actually I think we've moved up to 3.2 and later now.)
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-04-2012, 01:12 AM   #14 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: texas
Posts: 49
raptor85 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
The MFMailComposeViewController class is built into the SDK. There's no downloading it. You just use it in your project.

You can't use it from the simulator. You have to run it on the device. It works perfectly. That is how you should send email from your application. Really, truly.

If it doesn't work, you need to fix your code.

We have 3 apps in the app store that all use that class to send email, and they support iOS 3.1 and later. (Actually I think we've moved up to 3.2 and later now.)
Thanks Duncan i'll work on it and let you if i find any difficulty in solving the
raptor85 is offline   Reply With Quote
Reply

Bookmarks

Tags
ipad, objective c, xcode 4.2

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: 398
13 members and 385 guests
7twenty7, AppsBlogger, comicool, Creativ, Dalia, dansparrow, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, pbart, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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