我试图在Outlook 2013中在vba中定义一个MailItem变量。但是,每次我键入Dim mail作为MailItem时,mailItem都会被更新为MailItem。据我所知,这不是一个正确的类型。当我尝试MsgBox TypeName(邮件)时,它显示了Nothing。
我不知道为什么会发生这种事。任何帮助都是非常感谢的。谢谢!
整个代码如下所示
Private Sub Items_ItemAdd(ByVal newMail As Object)
'On Error Resume Next
On Error GoTo ErrorHandler
Dim mail As Outlook.mailItem
If TypeName(newMail) = TypeName(mail) Then ***<-- I want this if block to execute. But it doesn't!***
Set mail = newMail
SaveAttachments (newMail)
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub发布于 2015-09-10 15:39:18
TypeName将显示活动对象的类型名称。如果它从未被初始化(null),您将看到"Nothing“
话虽如此,你到底什么时候看到模糊的说法改变了呢?在Outlook编辑器中?
https://stackoverflow.com/questions/32497882
复制相似问题