uipath发送邮件 —— Send Outlook Mail Message

Send Outlook Mail Message 发送邮件

一、参数说明

1、Body : 需要发送的邮件内容

2、Subject : 需要发送邮件标题

3、MailMessage : 需要转发的邮件信息,此字段只允许类型是MailMessage的对象,若填写该项则上面的Email属性(Body、Subject)不会生效

4、Account : 用于发送消息的帐户

5、SentOnBehalfOfName : 邮件发件人的显示名称。该字段仅支持字符串和字符串变量。

6、IsBodyHtml : 指定邮件内容是否以Html的格式生成

7、IsDraft : 指定邮件是否另存为草稿

8、Bcc : 邮件的密件抄送人

9、Cc : 邮件的抄送人

10、To :  收件人

二、附件添加

选择Attach Files之后,点击新建参数输入指定的文件路径或变量即可

三、场景应用示例

1、转发指定邮件

场景描述:根据需要,接收到指定的邮件标题或寄件人之后,将信息转发至指定的部门或指定负责人进行处理

(1)首先通过get outlook mail message获取到需要处理的邮箱的指定邮件,赋值给mailList变量

这里的mailFolder是邮件的目录,Filter是筛选条件,具体可参考 https://blog.csdn.net/hotkoko/article/details/113702025

(2)通过遍历所有筛选之后的邮件,进行转发给指定的收件人,若要指定多个收件人,可使用分号(;)隔开,如"ze@example.com;aa@example.com"

mailMessage参数填写的是邮件对象

注意:遍历时需要注意设置参数的类型为MailMessage,如下图所示

2、发送HTML格式邮件,并将需回复的原邮件以附件的形式发送

(1)上面的get outlook message还是想场景一中的类似,筛选出指定的邮件之后遍历处理(具体参照场景一图片说明)

(2)保存该邮件,保存的目的是之后以附件的形式发送。在save mail message中,item是指遍历的每一封邮件,Path.combine是路径拼接,图片的内容以邮件的标题命名并放在C盘下指定的位置

注意:在命名时需要注意邮件的标题可能会出现一些特殊字符导致命名保存失败,需提前处理,可以通过IF做预判

(3)发送邮件,这里的Body中以HTML的代码格式进行编辑,并勾选属性中的IsBodyHtml

(4)添加附件,这里附件的命名也可以通过定义变量

效果如下(有什么问题可以评论,互相学习):

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用SpringBoot发送邮件的示例代码,其中包括了如何发送带附件的邮件和如何开启TLS验证: ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.mail.MailProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.core.io.FileSystemResource; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessageHelper; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import java.io.File; @SpringBootApplication @EnableConfigurationProperties(MailProperties.class) public class MailApplication { @Autowired private JavaMailSender mailSender; @Autowired private MailProperties mailProperties; public static void main(String[] args) { SpringApplication.run(MailApplication.class, args); } public void sendMailWithAttachment() throws MessagingException { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(mailProperties.getUsername()); helper.setTo("recipient@example.com"); helper.setSubject("Test email with attachment"); // 添加附件 FileSystemResource file = new FileSystemResource(new File("attachment.txt")); helper.addAttachment("attachment.txt", file); // 发送邮件 mailSender.send(message); } } ``` 在application.properties文件中添加以下配置: ``` spring.mail.username=xxxxxxx@outlook.com spring.mail.password=xxxxxxxxx spring.mail.port=587 spring.mail.host=smtp-mail.outlook.com spring.mail.properties.mail.smtp.starttls.required=true ``` 注意:在使用Outlook发送邮件时,需要开启TLS验证,否则会显示匿名用户无法通过验证。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值