电子邮件签名应用程序Iphone

时间:2012-11-26 09:37:08

标签: iphone objective-c xcode

我正在制作一个电子邮件签名应用程序,允许用户签名并使用它们发送电子邮件,它们是签名名称(文本字段),内容(文本视图)和图像(图像视图),我将它们保存在数据库,以便如果用户从第二个视图上的表视图中选择签名名称,预览将显示在同一视图上,就像我从表视图中选择签名1然后在预览部分中,签名图像应显示在签名内容在(文本视图)中,然后在同一视图上我们按下发送(按钮)文本和图像从预览部分的文本视图将被复制到剪贴板然后在第三个视图中我可以将其粘贴到消息部分和发送电子邮件,是否可以这样做,如果是,我该如何实现它或任何其他想法如何做到这一点?

1 个答案:

答案 0 :(得分:0)

我有一种方法可以发送包含图片和消息的电子邮件..只需在.h文件中添加MFMessageComposeViewControllerDelegate并在项目中添加框架MessageUI.framework

-(void)sendMailWithImage:(NSString *)message Image:(UIImage *)image{
    if ([MFMailComposeViewController canSendMail]) 
    {
        UIImage *tempImageSave=image;
        MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
        NSString *mailBody = message;

        NSData *imageData = UIImagePNGRepresentation(tempImageSave);
        [mailComposeViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@"Testing"];
        [mailComposeViewController setMessageBody:mailBody isHTML:NO];
        mailComposeViewController.mailComposeDelegate = self;
        [self presentViewController:mailComposeViewController animated:YES completion:nil];
    } 
    else 
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"e-Mail Sending Alert"
                                                        message:@"You can't send a mail"
                                                       delegate:nil
                                              cancelButtonTitle:@"OK" 
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

}

这个贝娄方法是MFMessageComposeViewControllerDelegate

的委托方法
#pragma mark - MFMessage Delegate

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    if (result == MFMailComposeResultSent) 
    {
        NSLog(@"\n\n Email Sent");
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

我希望这可以帮助你...