我想爲我的團隊使用電子郵件功能的自動化,我也是一個菜鳥,所以請原諒這裏的基本代碼。我收到錯誤消息91對象變量或帶塊變量未設置對象變量或有塊變量未設置(錯誤91)請協助
下面是代碼:
Sub Notification()
Dim outobj, mailobj
Dim objUserPrmt1 As Object
Dim strUserPrmt1
Dim message, title, defaultValue As String
message = "Enter your issue"
title = "InputBox Demo"
defaultValue = "No Issue"
Set outobj = CreateObject("Outlook.Application")
Set mailobj = outobj.CreateItem(0)
Set strUserPrmt1 = objUserPrmt1.CreateItem(InputBox(message, title, defaultValue, 25, 45))
With mailobj
.To = "[email protected]"
.Subject = "Notification:" strUserPrmt1
.Body = "Test"
'.Send
.Display
End With
'Clear the memory
Set outobj = Nothing
Set mailobj = Nothing
Set strUserPrmt1 = Nothing
Set objUserPrmt1 = Nothing
End Sub
希望有人能告訴我在哪裏我都失敗了。
這是VBA而不是VBScript。 objUserPrmt1被使用但從未初始化。 –
也許你的問題是'strUserPrmt1'。將它聲明爲'string'並使用'strUserPrmt1 = InputBox(message,title,defaultValue,25,45)'。 –
不知道我需要初始化的地方,你能提供一個例子嗎? –