|
我想实现的功能是:
Excel 自动发送邮件,现在的代码可以实现弹出如下的界面,但还需要自己手动点击发送,要是有很多次的话,手动点击就比较麻烦。
所以我想Excel是否可控制Foxmail发送的快捷键(Ctrl+Enter),只接发送,不需要弹出如下的对话框。
- Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
- Sub 多人批量发邮件() '一次发给多人邮件 【Ctrl+Enter Foxmail 发送邮件快捷键】
- Dim rng As Range, MyMail As String, str As String, Temp As String, i As Integer
- For Each rng In Range([c2], Cells(Rows.Count, 3).End(xlUp)) '遍历C列所有非空单元格(标题除外)
- str = str & rng.Text & ";" '串连所有数据,以";"分隔
- Next
- For Each rng In Range([A2], Cells(Rows.Count, 2).End(xlUp)) ''遍历B列所有非空单元格(标题除外)
- i = i + 1 '累加变量
- Temp = Temp & rng.Text & IIf(i Mod 2, " ", "%0A") '串连所有数据,用空格或者换行符"%0A"分隔
- Next
- MyMail = "mailto:" & Mid$(str, 1, Len(str) - 1) & "?subject=成绩通知&body=成绩表:%0A" & Temp & "%0A%0A" + Space(20) & "通知日期:" & Date
- ShellExecute 0&, vbNullString, MyMail, vbNullString, vbNullString, 1 '发邮件
- Application.SendKeys "^~"
- End Sub
复制代码
如上代码,我加了个 Application.SendKeys "^~" 不能够控制Foxmail发送邮件,麻烦大家看一下,谢谢。
Excel 分批发邮件.rar
(15.46 KB, 下载次数: 635)
该贴已经同步到 zhoucs00的微博 |
|