2010-12-06 93 views
1

我嘗試使用自定義內容類型從應用程序發送電子郵件。iPhone:使用自定義內容類型發送電子郵件

任何想法如何做到這一點?

所以我喜歡改變

「的Content-Type」: 「多/混合;邊界=蘋果郵件1--209662383」 - >「應用/ PKCS7-MIME;名稱= SMIME。 P7M; SMIME型=包封數據」

和 「內容傳輸編碼」:

「7位」 - > 「的base64」

+1

是否有某些原因,您不能將它作爲附件進行編碼? – 2010-12-06 09:54:36

+0

是的,我不想發送加密的smime附件,然後「Content-Type」必須是「application/pkcs7-mime; name = smime。P7M; smime-type = enveloped-data「和」Content-Transfer-Encoding「必須是」base64「 – x2on 2010-12-06 10:20:12

回答

-1
  • (無效)launchInAppMail {

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

    controller.mailComposeDelegate = self;

    [controller setSubject:@「In app email ...」];

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

    如果((mNameField.text ==零|| [mNameField.text isEqualToString:@ 「」]!)){

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

    } 如果((mPhoneNumberField.text ==零||! [mPhoneNumberField.text isEqualToString:@「」])) {messageString appendFormat:@「Phone Number:%@ \ n」,mPhoneNumberField.text];

    }

    如果((mEmailField.text ==零||![mEmailField.text isEqualToString:@ 「」])){ [messageString appendFormat:@ 「電子郵件ID:%@ \ n」 個, mEmailField.text]; }

    如果((mTextView.text ==零|| [mTextView.text isEqualToString:@ 「」]!)){

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

    }

    如果((mProblemNameButton.titleLabel!的.text ==零|| [mProblemNameButton.titleLabel.text isEqualToString:@ 「」])){

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

    }

    [messageString appendFormat:@「Address:%@ \ n」,self.mAddress];

    如果(self.coordinateLoc)

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

    [控制器setToRecipients:[NSArray的arrayWithObject:@「服務@ emergencylocksmithleads。COM「]];

    [控制器setMessageBody:messageString isHTML:NO];

    [messageString釋放];

    如果(!mImageView.image =無){

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

    }

    [self presentModalViewController:controller animated:YES];

    [控制器釋放]; }

編注標記--------------------------------------- -----

編譯標記MFMailComposeViewController委託方法

  • (無效)mailComposeController:(MFMailComposeViewController *)控制器didFinishWithResult:(MFMailComposeResult)結果錯誤:(NSError )錯誤{ 開關(結果){
    case MFMailComposeResultCallled:
    NSLog(@「郵件發送取消。」);
    /
    執行您在此處取消事件代碼... /
    休息;
    case MFMailComposeResultSaved:
    NSLog(@「Mail saved。」);
    /
    在這裏執行您的電子郵件保存事件代碼... */
    break;
    case MFMailComposeResultSent:{UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@「Mail Sent」message:nil delegate:self cancelButtonTitle:@「OK」otherButtonTitles:nil]; alert.tag = 1; alert.delegate = self; [alert show]; [警報發佈]; 休息;
    } case MFMailComposeResultFailed:{UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@「Mail Sending Failed」message:nil delegate:self cancelButtonTitle:@「OK」otherButtonTitles:nil]; alert.tag = 2; alert.delegate = self; [alert show]; [警報發佈]; 休息;
    } 默認值:
    break;
    } [controller dismissModalViewControllerAnimated:YES]; }
相關問題