如何通过Excel VBA和Outlook实现自动发送邮件功能

如题所述

可以直接使用API函数ShellExecute
复制下面的代码,直接粘贴到你的代码模块中,然后运行EmailSend即可看到效果。
Option Explicit
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 EmailSend()
Dim receiver$, MyMail$, MySubject$
receiver = "[email protected]"
MySubject = "试试看"
MyMail = "mailto:" & receiver & "?subject=" & MySubject & "&body=Linie:这是一个测试"
ShellExecute 0&, vbNullString, MyMail, vbNullString, vbNullString, 1
End Sub
温馨提示:答案为网友推荐,仅供参考