iPhone:使用自定义内容类型发送电子邮件

时间:2010-12-06 09:51:34

标签: iphone email iphone-sdk-3.0 ios ios4

我尝试使用自定义内容类型从应用发送电子邮件。

任何想法如何做到这一点?

所以我想改变

“内容类型”: “multipart / mixed; boundary = Apple-Mail-1--209662383” - > “application / pkcs7-mime; name = smime.p7m; smime-type = enveloped-data”

和 “内容传输编码”:

“7bit” - > “BASE64”

2 个答案:

答案 0 :(得分:1)

我使用http://code.google.com/p/skpsmtpmessage/向iOS发送自定义邮件。

答案 1 :(得分:-1)

  • (void)launchInAppMail {

    MFMailComposeViewController * controller = [[MFMailComposeViewController alloc] init];

    controller.mailComposeDelegate = self;

    [controller setSubject:@“在app email ...”];

    NSMutableString * messageString = [[NSMutableString alloc] init];

    if(!(mNameField.text == nil || [mNameField.text isEqualToString:@“”])){

    [messageString appendFormat:@"Name: %@ \n",mNameField.text];
    

    } if(!(mPhoneNumberField.text == nil || [mPhoneNumberField.text isEqualToString:@“”])) {     [messageString appendFormat:@“电话号码:%@ \ n”,mPhoneNumberField.text];

    }

    if(!(mEmailField.text == nil || [mEmailField.text isEqualToString:@“”])){     [messageString appendFormat:@“电子邮件ID:%@ \ n”,mEmailField.text]; }

    if(!(mTextView.text == nil || [mTextView.text isEqualToString:@“”])){

    [messageString appendFormat:@"Desription: %@ \n",mTextView.text];
    

    }

    if(!(mProblemNameButton.titleLabel.text == nil || [mProblemNameButton.titleLabel.text isEqualToString:@“”])){

    [messageString appendFormat:@"Problem Name:  %@ \n",mProblemNameButton.titleLabel.text];
    

    }

    [messageString appendFormat:@“Address:%@ \ n”,self.mAddress];

    if(self.coordinateLoc)

    [messageString appendFormat:@"Longitude: %f, Latitude: %f \n", self.coordinateLoc.coordinate.longitude, self.coordinateLoc.coordinate.latitude];
    

    [controller setToRecipients:[NSArray arrayWithObject:@“service@emergencylocksmithleads.com”]];

    [controller setMessageBody:messageString isHTML:NO];

    [messageString release];

    if(mImageView.image!= nil){

    NSData *imageData = UIImageJPEGRepresentation(mImageView.image, 1);
    
    
    [controller addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"example.jpg"];
    

    }

    [self presentModalViewController:controller animated:YES];

    [控制器发布]; }

pragma mark -------------------------------------------- < / H1>

pragma mark MFMailComposeViewController委托方法

  • (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError )error { 开关(结果){
        case MFMailComposeResultCancelled:
            NSLog(@“邮件发送已取消。”);
            /
             在这里执行取消事件的代码......           /
            打破;
        case MFMailComposeResultSaved:
            NSLog(@“Mail saved。”);
            /
             在此执行您的电子邮件保存事件代码...          * /
            打破;
        case MFMailComposeResultSent:{         UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@“Mail Sent”消息:nil delegate:self cancelButtonTitle:@“OK”otherButtonTitles:nil];         alert.tag = 1;         alert.delegate = self;         [警示显示];         [警告发布];         打破;
        }     case MFMailComposeResultFailed:{         UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@“Mail Sending Failed”消息:nil delegate:self cancelButtonTitle:@“OK”otherButtonTitles:nil];         alert.tag = 2;         alert.delegate = self;         [警示显示];         [警告发布];         打破;
        }     默认:
            打破;
    } [controller dismissModalViewControllerAnimated:YES]; }