HELP HERE!!
Maybe someone is able to help me.
I am trying to do the same. attach string to an email from iphone app.
The part of facebook and twitter is already working fine...but i havent been able to do it in the part of message.
thanks for your help! i really appreciate it...
I attach first the email part, and then bellow the twitter code...(maybe it is usefull for you).
email part:
-----------
-(IBAction)send:(id)sender
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Check this!"];
// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"Default"];
// Fill out the email body text
NSString *emailBody = [NSString stringWithString:[webView stringByEvaluatingJavaScriptFromString:@"document. documentElement.innerHTML"]];
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
- (void)mailComposeController:(MFMailComposeViewCont roller*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
webView.hidden = NO;
[self dismissModalViewControllerAnimated:YES];
}
----------
twitter part:
-(IBAction)twitStatus:(id)sender
{
NSString *content=[NSString stringWithString:[webView stringByEvaluatingJavaScriptFromString:@"document. documentElement.innerHTML"]];
NSRange data=[content rangeOfString:@"</font></center>"];
NSString *author=[content substringToIndex:data.location];
data=[author rangeOfString:@"<br></i>"];
author=[author substringFromIndex:data.location+8];
NSRange data2=[content rangeOfString:@"<br></i>"];
NSString *phrase = [content substringToIndex:data2.location];
data2=[phrase rangeOfString:@"<i><br>"];
phrase=[phrase substringFromIndex:data2.location+7];
phrase=[NSString stringWithFormat:@"%@ - %@",phrase,author ];
[[TwitterAgent defaultAgent] twit:phrase];
}
-----
|