如何用VBA实现EXCEL发邮件功能
我的EXCEL是2003版的,发邮件用的是winxp自带OUTLOOKExpress,网上查的CreateObject("Outlook.Application")这个是...
我的EXCEL是2003版的,发邮件用的是winxp自带OUTLOOK Express,网上查的CreateObject("Outlook.Application")这个是用不了的。CDO功能太麻烦,不好用,我觉得Excel自带的发邮件功能很好用。但是用录制的方法却录不到。见附图,有没有方法实现相同的功能。谢谢
展开
展开全部
1.添加引用Microsoft Outlook 11.0 Object Library。(这里用的是Microsoft Outlook
2003)
2.定义发送邮件过程。
Public Sub SendEmail(Receiver As String, SubjectText As String, BodyText As
String, AttachedObject As String)
Dim OutlookApp As
Outlook.Application
Dim OutlookItem As
Outlook.MailItem
Set OutlookApp =
New Outlook.Application
Set OutlookItem =
OutlookApp.CreateItem(olMailItem)
On Error GoTo
SendEmail_Error
With
OutlookItem
.To = Receiver
'收件人地址
.Subject = SubjectText
'邮件主题
.Body = BodyText
'邮件内容
.Attachments.Add
AttachedObject '粘贴附件
.Send
'发送邮件
End With
SendEmail_Exit:
Exit
Sub
SendEmail_Error:
MsgBox
Err.Description
Resume SendEmail_Exit
End Sub
2003)
2.定义发送邮件过程。
Public Sub SendEmail(Receiver As String, SubjectText As String, BodyText As
String, AttachedObject As String)
Dim OutlookApp As
Outlook.Application
Dim OutlookItem As
Outlook.MailItem
Set OutlookApp =
New Outlook.Application
Set OutlookItem =
OutlookApp.CreateItem(olMailItem)
On Error GoTo
SendEmail_Error
With
OutlookItem
.To = Receiver
'收件人地址
.Subject = SubjectText
'邮件主题
.Body = BodyText
'邮件内容
.Attachments.Add
AttachedObject '粘贴附件
.Send
'发送邮件
End With
SendEmail_Exit:
Exit
Sub
SendEmail_Error:
MsgBox
Err.Description
Resume SendEmail_Exit
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |