Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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 02-22-2009, 08:12 AM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 9
Default Help with e-mailing displayLabel text

My app is a single window app currently with a text label and a button. When you press the button the text label updates with random text from a local database. I'd like to add the functionality to e-mail the current display text with a separate e-mail button down below. I am posting the current button functionality and was looking for some assistance to see if it is possible to capture the current displayLabel text with a new button.

Current code:
Code:
/*!
    @function	tapButtonPressed
    @discussion This function is called when "Tap Me Now" button is pressed
    @param      sender
    @result     displays the random text from the database in Label
*/
-(IBAction)tapButtonPressed:(id)sender
{	
	ShakeMeAppDelegate *appDelegate = (ShakeMeAppDelegate *)[[UIApplication sharedApplication] delegate];
	
	NSInteger randomNumber = [self getRandomIndex];
	//NSLog(@"Selected shake text is %@", [[appDelegate.shakeTexts objectAtIndex:randomNumber] text]);
	displayLabel.text = [[appDelegate.shakeTexts objectAtIndex:randomNumber] text];
	
}
aschaef is offline   Reply With Quote
Old 02-22-2009, 10:41 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 428
Default

you do realise that you need to somehow capture the mail recipient address, right?

generally you can use the "mailto:" URL scheme to send mails (and include your text in the body of the message). Be aware that this will close your program and open mobile mail.
lbendlin is offline   Reply With Quote
Old 02-22-2009, 11:39 PM   #3 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 9
Default

Can I just pass the subject and body text and have the user enter the To: address once they are passed to the mail app, or does the url just call the mail app and everything has to be pre-entered?
aschaef is offline   Reply With Quote
Old 02-22-2009, 11:48 PM   #4 (permalink)
New Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
Default

Just call openURL with:

@"mailto:?subject=<escaped subject>&body=<escaped body text>"

This will launch mobile mail with the subject and body prepopulated. The user must then pick one or more email addresses and tap the Send button.
RickMaddy is offline   Reply With Quote
Old 02-23-2009, 07:57 AM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 9
Default

Quote:
Originally Posted by RickMaddy View Post
Just call openURL with:

@"mailto:?subject=<escaped subject>&body=<escaped body text>"

This will launch mobile mail with the subject and body prepopulated. The user must then pick one or more email addresses and tap the Send button.
That would work just fine to start until I can mess around with the other sdk which will allow you to send e-mails from within the application. Does anyone have any suggestion on how I can get the displayLabel.text value into the body string of the e-mail url? I'm sorry if this is really simple, but this is my first app and everything is still very confusing to me lol.
aschaef is offline   Reply With Quote
Old 02-24-2009, 08:56 AM   #6 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 9
Default

Quote:
Originally Posted by aschaef View Post
My app is a single window app currently with a text label and a button. When you press the button the text label updates with random text from a local database. I'd like to add the functionality to e-mail the current display text with a separate e-mail button down below. I am posting the current button functionality and was looking for some ***istance to see if it is possible to capture the current displayLabel text with a new button.

Current code:
Code:
/*!
    @function	tapButtonPressed
    @discussion This function is called when "Tap Me Now" button is pressed
    @param      sender
    @result     displays the random text from the database in Label
*/
-(IBAction)tapButtonPressed:(id)sender
{	
	ShakeMeAppDelegate *appDelegate = (ShakeMeAppDelegate *)[[UIApplication sharedApplication] delegate];
	
	NSInteger randomNumber = [self getRandomIndex];
	//NSLog(@"Selected shake text is %@", [[appDelegate.shakeTexts objectAtIndex:randomNumber] text]);
	displayLabel.text = [[appDelegate.shakeTexts objectAtIndex:randomNumber] text];
	
}
Does the email function need to go within the button tap function, or can i just reference the displayLabel.text in a separate button press function?
aschaef 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


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 226
16 members and 210 guests
benoitr007, Breshi, codezy, dbonneville, irishkiwi, Jompe71, leeks, mizyeh, myPhone, n8r0n, Oliver Drobnik, pkouame, prathumca, Rashomon, smilespray, their
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,279
Threads: 39,072
Posts: 171,328
Top Poster: smasher (2,575)
Welcome to our newest member, yogen81
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:12 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0