iOS URL Scheme Microsoft Outlook App

Lav*_*vvo 4 outlook url-scheme ios

这似乎是不可能找到的,除非也许没有一个.但有人知道(如果有的话)iOS URL方案,用于打开Microsoft Outlook移动应用程序,直接使用预定义的TO_EMAIL,SUBJECT和BODY进行撰写屏幕?

Kin*_*ech 12

这是我发现的一个链接,帮助我解决了IOS Outlook URL方案.

从那以后我就能想出这个代码:

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

// 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 = fieldSubject.text;
// Encode the string for URL.
NSString* encodedSubject = [emailSubject stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
// Get the email body from the body text field.
NSString* emailBody = fieldBody.text;
// Encode the string for URL.
NSString* encodedBody = [emailBody 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];
Run Code Online (Sandbox Code Playgroud)

Outlook的URL方案是:ms-outlook:// compose?to=example@email.com&subject=Subject&body=Message

希望这可以帮助!

  • Outlook for iOS 版本 4.14.x 及更高版本(截至本文发布时为 4.15.0)似乎已损坏。编码后的 HTML 已删除所有标记分隔符,因此 &lt;br&gt;&lt;p&gt; 变为 brp。我尝试了一些其他 URL 允许的字符集编码,但没有成功。我认为他们不再允许通过该 Body 参数传入 HTML,但找不到官方文档。有任何想法吗? (5认同)
  • 我发现你的答案非常有帮助.唯一缺少的就是附件.你能帮我吗? (2认同)