Loading

Saturday, June 12, 2010

eMail Functions

1 -> -(void) prepareHmlDataAndSendEmail
{

CGRect tmp=CGRectMake(0 ,80,320,480);
[Scroll_View_Img_Cone scrollRectToVisible:tmp animated:NO];

Seg_Ctrl.hidden=YES;
Flag_Srl=Scroll_View.hidden;
Flag_Srl_Cone=Scroll_View_Cone.hidden;
Flag_Srl_ICream=Scroll_View_ICream.hidden;
Flag_Srl_Topping=Scroll_View_Topping.hidden;

Scroll_View.hidden=YES;
Scroll_View_Cone.hidden=YES;
Scroll_View_ICream.hidden=YES;
Scroll_View_Topping.hidden=YES;


UIImageView *Img_Screen=[[UIImageView alloc]init];
UIGraphicsBeginImageContext(self.view.bounds.size); //self.view.window.frame.size
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
Img_Screen.image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();



MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

NSString * HTMLData = @"Hi,

";
picker.navigationController.navigationBar.barStyle = UIBarStyleBlack;
[picker setSubject:@"Tasty Ice-Cream"];
NSArray *toRecipients = [NSArray arrayWithObject:@""];
[picker setToRecipients:toRecipients];
[picker setMessageBody:HTMLData isHTML:YES];
if(Img_Screen.image != nil){
[picker addAttachmentData: UIImagePNGRepresentation(Img_Screen.image) mimeType: @"image/png" fileName:@"Ice-Cream.png"];
}
// Add Some String TO Bottom :)
Img_Screen.frame=CGRectMake(0,0,320,100);
Img_Screen.image=[UIImage imageNamed:[NSString stringWithFormat:@"Bottom Picture.png"]];
if(Img_Screen.image != nil)
{
[picker addAttachmentData: UIImagePNGRepresentation(Img_Screen.image) mimeType: @"image/png" fileName:@"Ice-Cream.png"];
}

[self presentModalViewController:picker animated:YES];
[picker release];

[Img_Screen release];

Scroll_View.hidden=Flag_Srl;
Scroll_View_Cone.hidden=Flag_Srl_Cone;
Scroll_View_ICream.hidden=Flag_Srl_ICream;
Scroll_View_Topping.hidden=Flag_Srl_Topping;
Seg_Ctrl.hidden=NO;


tmp=CGRectMake(0,0,320,480);
[Scroll_View_Img_Cone scrollRectToVisible:tmp animated:NO];
}



2--> Customize Message
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{

switch (result)
{
//UIAlertView * alert = [UIAlertView alloc];
case MFMailComposeResultCancelled:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Cancelled" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
case MFMailComposeResultSaved:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Saved" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
case MFMailComposeResultSent:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Sent" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
case MFMailComposeResultFailed:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Failed" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
default:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Not Sent" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
}

[self dismissModalViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:YES];
}

3--> Remember to Add MessageUI.FrameWork

No comments:

Post a Comment