1.所需控件 MAPI 控件(两个都要,默认Name),CommandButton 控件(默认Name,Caption为“发送邮件”)。
2.声明变量如下:
Dim strMailAdd As String '收信人地址
Dim strAddName As String '收信人姓名
Dim strSubject As String '发信的主题
Dim strNoteText As String '发信的内容
Dim strMailToo As String '发信人地址
DIm strTooName As String '发信人姓名
3.程序开始
Private Sub Form_Load()
strMailAdd = "xxx@21cn.com" '收信人地址
strAddName = "xxx" '收信人姓名
strSubject = "VB爱好者" '发信的主题
strNoteText = "xxxx" '发信的内容
End Sub
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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
ShellExecute Me.hwnd, vbNullString, "mailto:lihonggen0@163.net", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Set App = CreateObject("Outlook.Application")
Set Itm = App.CreateItem(0)
With Itm
.Subject = "A tip from vbCode Magician"
.To = "newvb@21cn.com"
.Body = "认住新VB,真材实料有保证"
.Send
End With