|
如下代码不需要引用
- Sub test()
- SendToSubjBody "125788855@126.com", True, "tevst", "body", "D:\test.xls", True
- End Sub
- Public Sub SendToSubjBody(strTo As String, _
- bolHTML As Boolean, _
- strSubj As String, _
- strbody As String, _
- AttachmentFileName As String, _
- Optional AutoSend As Boolean = True)
-
- Dim ola1 As Object
- Dim mai1 As Object
- Set ola1 = CreateObject("Outlook.Application")
- Set mai1 = ola1.CreateItem(olMailItem)
- With mai1
- .to = strTo '地址
- .Subject = strSubj '主题
-
- If bolHTML = True Then
- .HTMLBody = strbody '内容
- Else
- .Body = strbody
- End If
-
- If Len(AttachmentFileName) > 0 Then
- .attachments.Add AttachmentFileName
- End If
-
- If AutoSend = True Then
- .Send
- Else
- .display
- End If
- End With
- End Sub
复制代码 |
|