2016-05-18 13 views
2

ファイルを生成し、すべての電子メールフィールドを埋め込んで、ユーザーが本文を入力するだけのアプリケーションを作成しようとしています。また、ネイティブのiOSメールアプリとMicrosoft Outlookアプリ(インストールされている場合)のどちらかを選択することもできます。
ネイティブ電子メールアプリで送信する電子メールを準備するときに、私はMessageUIフレームワークを使用してファイルを簡単に添付しましたが、OutlookアプリケーションではURLスキーム(ms-outlook://)を使用する必要がありますファイルを添付するための簡単な方法です。
誰かがOutlookアプリから別のアプリからの添付ファイルを正常に送信しましたか?URLスキーム添付ファイルMicrosoft Outlookアプリケーション

+0

解決策は見つかりましたか? –

+0

まだありません。私はOutlookチームに尋ねましたが、彼らは今は不幸にもこれをサポートしていないと言いました。 – tx2

+0

私はmyslefを把握することができました。私はここに解決策を掲示すべきですか? –

答えて

0

私は「何かが何よりも良い」に基づいてこの回答を投稿しています。私はiOS Appを使ってあらかじめ添付されたファイルを電子メールで送ることができないことを知っているので、少なくとも電子メールで画像ファイルを送信できる方法を見つけることができました。

// Create an array of recipients for the email. 
NSArray* emailRecipients = @[@"[email protected]", @"e[email protected]"]; 

// Create a mutable string to hold all of the recipient email addresses and add the first one. 
NSMutableString* emailTo = [[NSMutableString alloc] initWithString:emailRecipients[0]]; 

// Loop through all of the email recipients except for the first one. 
for (int index = 1; index < emailRecipients.count; index++) 
{ 
    // Add a semicolon and then the email address at the current index. 
    [emailTo appendFormat:@";%@", emailRecipients[index]]; 
} 

// Get the email subject from the subject text field. 
NSString *emailSubject = @"Your Email Subject"; 

// Encode the string for URL. 
NSString *encodedSubject = [emailSubject stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; 

// Define your image's size 
NSString *htmlBody = (@"<div style=\"width:450px;height:797px;\"><img src=\"http://your_website.com/your_image.jpg\" style=\"width:100%;height:100%;\"></div>"); 

// Encode the string for URL. 
NSString* encodedBody = [htmlBody stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; 

// See if the subject or body are empty. 
if (![emailSubject length] || ![emailBody length]) 
{ 
    // Exit. 
    return; 
} 

// Create a string with the URL scheme and email properties. 
NSString *stringURL = [NSString stringWithFormat:@"ms-outlook://compose?to=%@&subject=%@&body=%@", emailTo, encodedSubject, encodedBody]; 
// Convert the string to a URL. 
NSURL *url = [NSURL URLWithString:stringURL]; 
// Open the app that responds to the URL scheme (should be Outlook). 
[[UIApplication sharedApplication] openURL:url]; 

これは、電子メール本体に埋め込まれたイメージファイルを簡単に送信します。画像に合わせてサイズを調整する必要があるかもしれません。

関連する問題