如何使用VBA调用outlook发送邮件源码 15
1个回答
展开全部
'将发件箱中的邮件发送出去
Sub subSendEmail()
On Error Resume Next
Dim fld_OutBox As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim myItem As Object
Dim myItems() As Object
Dim iIndex As Integer
iIndex = 0
Dim n As Integer
'获得发件箱
Set fld_OutBox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox)
Set objItems = fld_OutBox.Items
If fld_OutBox.Items.Count = 0 Then
'如果发件箱邮件数为0从草稿箱中移动邮件
'从草稿箱中移动若干邮件到发件箱
funMoveMailToOutBox 15
End If
'如果发件箱存在对象,对其中的邮件执行发送
If objItems.Count > 0 Then
For n = 1 To objItems.Count
If (objItems(1).Class = 43) Then
'发送邮件
objItems(n).Send
End If
Next n
End If
End Sub
Sub subSendEmail()
On Error Resume Next
Dim fld_OutBox As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim myItem As Object
Dim myItems() As Object
Dim iIndex As Integer
iIndex = 0
Dim n As Integer
'获得发件箱
Set fld_OutBox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox)
Set objItems = fld_OutBox.Items
If fld_OutBox.Items.Count = 0 Then
'如果发件箱邮件数为0从草稿箱中移动邮件
'从草稿箱中移动若干邮件到发件箱
funMoveMailToOutBox 15
End If
'如果发件箱存在对象,对其中的邮件执行发送
If objItems.Count > 0 Then
For n = 1 To objItems.Count
If (objItems(1).Class = 43) Then
'发送邮件
objItems(n).Send
End If
Next n
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询