|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我的实验
1. 下载控件并注册。 Regsvr32 C:\WINNT\system32\osmax.ocx
2. 编码如下。
Private Sub CommandButton1_Click()
Call SMAIL("jianwu.zhang@siemens.com", "only check", "check", "d:\temp\aa.txt")
End Sub
Public Function SMAIL(TV, Subj, BOD, Att)
On Error Resume Next
Dim rowCount, endRowNo
Dim objOutlook As New Outlook.Application
Dim objMail As mailitem
'´´½¨objOutlookΪOutlookÓ¦ÓóÌÐò¶ÔÏó
Set objOutlook = New Outlook.Application
DisablePrompt objOutlook
'´´½¨objMailΪһ¸öÓʼþ¶ÔÏó
Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = TV 'ÉèÖÃÊÕ¼þÈ˵ØÖ·
.Subject = Subj '"ÓʼþÖ÷Ìâ"
.Body = BOD
.Attachments.Add Att 'ÉèÖø½¼þ
.Send
End With
'Ïú»ÙobjMail¶ÔÏó
Set objMail = Nothing
'Ïú»ÙobjOutlook¶ÔÏó
Set objOutlook = Nothing
End Function
Function DisablePrompt(ByRef object)
Dim tmp
Set object = CreateObject("outlook.application") ‘此定义特别重要。
Set tmp = CreateObject("addinexpress.outlooksecuritymanager")
tmp.ConnectTo (object)
tmp.DisableOOMWarnings = True
tmp.DisableCDOWarnings = True
tmp.DisableSMAPIWarnings = True
End Function
然后就可以了。 |
|