0
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myitems = myInbox.Items
For Each myitem In myitems
If myitem.Class = olMail Then
If InStr(1, myitem.Subject, "Greetings") > 0 Then
senderemail = myitem.Sender.GetExchangeUser.PrimarySmtpAddress
If senderemail = "[email protected]" Then
Set oMail = myitem.Forward
oMail.Recipients.Add "[email protected]"
oMail.HTMLBody = "Hi"
oMail.Display
End If
End If
End If
Next myitem
我的代碼可以在幾個星期前正常運行。今天我再次運行並調試它我發現一旦涉及到Set oMail = myitem.Forward我得到一個outlook窗口打開並且運行時錯誤顯示應用程序定義或對象定義的錯誤。由於運行時錯誤導致無法轉發電子郵件'287'
如何在同一時間獲得轉發電子郵件和錯誤?首先,我只是在顯示命令後才使用Outlook窗口。也由於這個原因,我無法執行我的轉發郵件中的下一行代碼。
編輯:
而且現在我看到的是直接顯示郵件不給任何錯誤,但是一旦我用的.forward命令這是當錯誤出現。
什麼版本的Outlook?有一個選項可以在信任中心設置中實現自動化。 – Sorceri