diff --git a/zh-cn/react-native-mail.md b/zh-cn/react-native-mail.md new file mode 100644 index 0000000000000000000000000000000000000000..b6be454fd656a7a758a93b8956d896b2c4833f89 --- /dev/null +++ b/zh-cn/react-native-mail.md @@ -0,0 +1,228 @@ + + +> 模板版本:v0.2.2 + +

+

react-native-mail

+

+ +

+ + Supported platforms + + + License + + +

+ +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-mail) + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息:[https://github.com/react-native-oh-library/react-native-mail Releases](https://github.com/react-native-oh-library/react-native-mail/releases),并下载适用版本的 tgz 包 + +进入到工程目录并输入以下命令: + +>[!TIP] # 处替换为 tgz 包的路径 + + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/react-native-mail@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/react-native-mail@file:# +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```jsx +import React, { Component } from 'react'; +import { View, Alert, Button } from 'react-native'; +import Mailer from 'react-native-mail'; + +export default class App extends Component { + + handleEmail = () => { + Mailer.mail({ + subject: 'need help', + recipients: ['support@example.com'], + ccRecipients: ['supportCC@example.com'], + bccRecipients: ['supportBCC@example.com'], + body: 'A Bold Body', + customChooserTitle: 'This is my new title', // Android only (defaults to "Send Mail") + isHTML: true, + attachments: [{ + // Specify either `path` or `uri` to indicate where to find the file data. + path: '', // /data/storage/el2/base/haps/entry/files/11.png + uri: '', // file:///data/storage/el2/base/haps/entry/files/11.png + // Specify either `type` or `mimeType` to indicate the type of data. + type: '', // Mime Type: jpg, png, doc, ppt, html, pdf, csv + mimeType: '', // - use only if you want to use custom type + name: '', // Optional: Custom filename for attachment + }] + }, (error, event) => { + Alert.alert( + error, + event, + [ + {text: 'Ok', onPress: () => console.log('OK: Email Error Response')}, + {text: 'Cancel', onPress: () => console.log('CANCEL: Email Error Response')} + ], + { cancelable: true } + ) + }); + } + + render() { + return ( + +