uniapp series - 2 solutions for using uniapp to carry recipient information to call mobile phone mail application to send mail

background description

After we use uniapp to package, in some cases, we need to use uniapp to open other applications on the mobile phone to send emails, carrying the email information and subject information of the other party, so how should we deal with it?

Solution 1: Use the uniapp tag - uni-link , note that this solution does not carry information such as the subject of the email

uni-link is an external webpage hyperlink component, copy the url in the applet, open the external browser in the app, and open a new webpage on the h5 side.

how to install

install sass

npm i sass -D

Install sass-loader

npm i [email protected] -D

Anso uni-ui

npm i @dcloudio/uni-ui

how to use

  • step1 Create a components directory under the same level path as the project pages
  • step2 Find the downloaded uni-ui under the node_modules folder
  • step3 Paste it into the src/components directory
  • step4 can be used directly according to the example on the official website, no need to register and import

platform compatibility

code example

<template>
	<uni-link href="mailto:[email protected]" text="点击这里给小金发邮件!" font-size="30"></uni-link>
	<uni-link href="https://uniapp.dcloud.io/" text="https://uniapp.dcloud.io/" showUnderLine="false" font-size="30">
	</uni-link>
</template>

<script>
</script>

<style>
	.uni-link {
		display: block;
		margin: 40rpx;
	}
</style>

Mobile phone effect display

After clicking the label, the effect is displayed


Solution 2: plus.messaging sends emails with attachments

For details, please visit my other article – uniapp series – how to use plus.messaging module to send SMS, MMS, email, etc.

upper code

<template>
	<uni-link href="mailto:[email protected]" text="点击这里给小金发邮件!" font-size="30"></uni-link>
	<uni-link href="https://uniapp.dcloud.io/" text="https://uniapp.dcloud.io/" showUnderLine="false" font-size="30">
	</uni-link>
	<button @tap="sendEmail">plus.messaging发送邮件</button>
</template>

<script setup>
	const sendEmail = () => {
		var mail = plus.messaging.createMessage(plus.messaging.TYPE_EMAIL);
		mail.to = ["[email protected]"];
		mail.subject = "发给小金的测试邮件";
		mail.body = "我今天很开心哦~";
		mail.bodyType = "text/html";

		plus.messaging.sendMessage(mail, function() {
			console.log("给小金的测试邮件发送成功啦");
		}, function(e) {
			console.log(e);
		});
	}
</script>

<style>
	.uni-link {
		display: block;
		margin: 40rpx;
	}
</style>

Effect

After clicking the label, the effect is displayed


I will write here today~

  • Friends, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ See you tomorrow~~
  • Everyone be happy every day

Everyone is welcome to point out where the article needs to be corrected~
Learning is endless, cooperation is win-win

insert image description here

Welcome the little brothers and sisters passing by to put forward better opinions~~

Guess you like

Origin blog.csdn.net/tangdou369098655/article/details/130120578