本文使用「署名 4.0 国际 (CC BY 4.0)」许可协议,欢迎转载、或重新修改使用,但需要注明来源。 [署名 4.0 国际 (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/deed.zh) 本文作者: 苏洋 创建时间: 2009年05月17日 统计字数: 637字 阅读时间: 2分钟阅读 本文链接: https://soulteary.com/2009/05/17/vb-post-mail.html ----- # [VB]发送邮件 一个发送邮件的函数。 ```vb 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 Private Const SW_SHOW = 5 Public Function SendEmail(ByVal strMail As String, _ Optional strSubject As String = "Subject", _ Optional strBody As String = "The Content Here.") As Boolean Dim lngRtn As Long, strTmp As String: lngRtn = 0 strTmp = "mailto:" & strMail & "?subject=" & strSubject & "&body=" & strBody lngRtn = ShellExecute(Me.hwnd, "open", strTmp, vbNullString, vbNullString, SW_SHOW) SendEmail = IIf(lngRtn = 0, False, True) End Function ```