wpsvba怎么发送邮件

办公教程导读

收集整理了【wpsvba怎么发送邮件】办公软件教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1493字,纯文字阅读大概需要3分钟

办公教程内容图文

Windows使用教程,Windows系统教程,Windows优化教程

4、发送电子邮件代码

Public Sub 发送电子邮件()

Dim OutlookApp As Outlook.Application

Dim newMail As Outlook.mailitem

Dim myAttachments As Outlook.Attachments

Dim n As Integer, i As Integer

Dim ws As Worksheet

On Error Resume Next

Set ws = Worksheets("邮件地址")

n = ws.Range("B65536").End(xlUp).Row

address = Worksheets("邮件地址").Cells(2, 2)

For i = 2 To n

If i < n Then

address = address & ";" & Worksheets("邮件地址").Cells(i + 1, 2)

End If

Next i

’CC

n = ws.Range("D65536").End(xlUp).Row

addressCC = Worksheets("邮件地址").Cells(2, 4)

For i = 2 To n

If i < n Then

addressCC = addressCC & ";" & Worksheets("邮件地址").Cells(i + 1, 4)

End If

Next i

’BCC

n = ws.Range("F65536").End(xlUp).Row

addressBCC = Worksheets("邮件地址").Cells(2, 6)

For i = 2 To n

If i < n Then

addressBCC = addressBCC & ";" & Worksheets("邮件地址").Cells(i + 1, 6)

End If

Next i

Set OutlookApp = New Outlook.Application

wbStr = ThisWorkbook.FullName ’指定要发送发工作簿名称字符串

Set newMail = OutlookApp.CreateItem(olMailItem) ’创建新邮件

With newMail

.Subject = Worksheets("邮件地址").Cells(2, 7) ’设置邮件主题

.Body = Worksheets("邮件地址").Cells(2, 8) ’设置邮件正文

’发送附件

Set myAttachments = newMail.Attachments

myAttachments.Add wbStr, olByValue, 1, "工作簿"

.To = address ’收件人

.CC = addressCC ’抄送

.BCC = addressBCC ’密送

.Send ’开始发送

End With

End Sub

5、最后添加加载菜单中按钮,链接到编写的程序模块;

然后我们在点击一下按钮运行程序,将邮件发送给相关收件人;

以后在需要发邮件,只需要点这个按钮即可。

Windows使用教程,Windows系统教程,Windows优化教程

办公教程总结

以上是为您收集整理的【wpsvba怎么发送邮件】办公软件教程的全部内容,希望文章能够帮你了解办公软件教程wpsvba怎么发送邮件
如果觉得办公软件教程内容还不错,欢迎将网站推荐给好友。

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » wpsvba怎么发送邮件