作者zmail (ZM)
看板Office
标题[算表] E-mail 批次邮件寄送不同附件to不同人
时间Tue Jun 15 17:46:19 2021
软体:
excel 2016
outlook 2016
说明:
可批次邮寄寄信(Excel版的合并列印),
给不同的使用者、不同的附件,
如寄送个人成绩单..等,
A会收到A成绩单
B会收到B成绩单
一次寄送多笔(如50笔以上手动寄信太麻烦,可参考此方法)
寄送前确认你的信箱不会被当成垃圾信,
如收件人未收到,
请收件人去垃圾邮件找看看。
如要直接改范例,请至文末(3)处下载後改即可。
(1)----空白excel建立方式------------
一.先登入outlook,预设outlook信箱,
会成为excel批次合并列印附件之寄件信箱
二.
1.开启EXCEL=>插入=>模组
2.在Module1贴上[程式码](参阅下方)。
3.Alt+Q返回 Excel。
4.
A1~A99..栏写【收件者姓名】
B1~B99..栏写【收件者Email】
C1~C99..栏写【附件在电脑内的路径】
5.您可以使用 Alt+F8然後选择脚本并运行它。
6.excel会自动开启outlook去寄信。
※上方为从空白试算表建立,Excel范例档可参考文末处。
(2)----程式码范例 -------
https://bit.ly/2TvHXr5
------------------
Option Explicit
Sub Send_Files()
'Working in Excel 2000-2016
'For Tips see:
http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim cell As Range
Dim FileCell As Range
Dim rng As Range
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set sh = Sheets("工作表1")
Set OutApp = CreateObject("Outlook.Application")
For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConstants)
'Enter the path/file names in the C:Z column in each row
Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1")
If cell.Value Like "?*@?*.?*" And _
Application.WorksheetFunction.CountA(rng) > 0 Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cell.Value
.Subject = "110年成绩单-"
.HTMLBody = "<H2><B>同学 " & cell.Offset(0, -1).Value & " 您好
:</B></H2>" & _
"<H3>1.收到学期成绩单,当你阅读完毕後,请记得填写下列回覆单<br></
H3>" & _
"<H3><A HREF=""
https://forms.gle/*******"">成绩确认回覆单:</A><
br></H3>" & _
"<H3><A HREF=""
https://forms.gle/*******"">https://forms.gle/***
****</A><br></H3>" & _
"<H3> 表示您已阅读完毕,也可以让老师进行最後一段毕业成绩结算事宜
,谢谢您的配合!<br></H3>" & _
"<br>" & _
"<H3>2.如果对成绩单有疑义的话,请来电23*******转*** 找老师询问.<br
></H3>" & _
"<br>" & _
"<br><br><B>Thank you</B>"
For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
If Trim(FileCell) <> "" Then
If Dir(FileCell.Value) <> "" Then
.Attachments.Add FileCell.Value
End If
End If
Next FileCell
.Send 'Or use .Display
End With
Set OutMail = Nothing
End If
Next cell
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
----程式码范例----
(3)-----范例档案与修改-------
修改email信件主旨与说明:
开启范例Excel含巨集试算表
1.ALT+F11打开程式码,点开模组的Module1程式码
从With OutMail行开始改
.Subject是主旨
.HTMLBody是信件内容,要写成HTML格式
cell.Offset(0, -1).Value 是抓A1栏姓名带入信件内
范例Excel巨集档案(下载後请启用巨集):
https://bit.ly/3vrnsci
范例图片:
https://imgur.com/i97MD9k.jpg
收件者收到的画面:
https://imgur.com/NfJDAKm.jpg
------------------------
关键字:合并列印 Email 邮件 寄送 不同附件 薪资单 成绩单
参考网页:
https://www.rondebruin.nl/win/s1/outlook/amail6.htm
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.167.183.177 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Office/M.1623750385.A.72D.html
※ 编辑: zmail (118.167.183.197 台湾), 06/22/2021 00:54:39