D
DraguVaso
Hi,
I have a VB.NET-application that has to open an email in Outlook. for this I
have some VBA-code in a MSScriptControl.
This works like always, but sometimes it thorws this error:
"
4/08/2004 08:16:56 Exception of type System.Exception was thrown.
DScriptControlSource_Event_Error DScriptControlSource_Event_Error
04/08/2004 08:16:56 The remote server machine does not exist or is
unavailable: 'golApp.GetNamespace' at
MSScriptControl.ScriptControlClass.Run(String ProcedureName, Object[]&
Parameters)
at VocalcomCetelem.frmAgent.AxToolbar1_MailSuccess(Object sender,
_IToolbarEvents_MailSuccessEvent e)
"
It seems that I have this errors when something is wrong with Outlook. I
thought that this happens when Outlook is closed, but after you start it up
it the error stays. Does anybody know why this happens like this?
Thanks a lot in advance!
Pieter
You can find the code here:
'*******VB.NET*************
'declaration of my ScriptControl
Private WithEvents sccMailScript As New MSScriptControl.ScriptControlClass
'initialiszation
sccMailScript.Language = "VBScript"
sccMailScript.AddObject("Toolbar", AxToolbar1, True)
'strText = the *.vbs
sccMailScript.AddCode(strText)
sccMailScript.Run("OnLoad")
'to open the email I run this:
sccMailScript.Run("OnMailSuccess")
'******END VB.NET*************
'******VBS*************
Dim golApp
Dim objInspector
Sub OnLoad
Set golApp = CreateObject("Outlook.Application.8") 'New
Outlook.Application
End Sub
Sub OnWrapupEnd
on error resume next
Application.Navigate ""
if not objInspector is nothing then
objInspector.Close(1)
end if
on error goto 0
End Sub
Sub OnMailSuccess
Dim gnspNameSpace
Dim gmfInbox
Dim gmiItem
Set gnspNameSpace = golApp.GetNamespace("MAPI")
for j=1 to gnspNameSpace.Folders.Count
if instr(1,gnspNameSpace.Folders.Item(j).Name,"Fax")>0 then
set gmfInbox = gnspNameSpace.Folders.Item(j).Folders.Item(4)
For i = 1 To gmfInbox.Items.Count
Set gmiItem = gmfInbox.Items.Item(i)
If gmiItem.EntryID = Toolbar.CallInformation(1).ItemID Then
Set objInspector = gmiItem.GetInspector
objInspector.Display
Exit For
End If
Next
end if
next
End Sub
'*******END VBS**************
I have a VB.NET-application that has to open an email in Outlook. for this I
have some VBA-code in a MSScriptControl.
This works like always, but sometimes it thorws this error:
"
4/08/2004 08:16:56 Exception of type System.Exception was thrown.
DScriptControlSource_Event_Error DScriptControlSource_Event_Error
04/08/2004 08:16:56 The remote server machine does not exist or is
unavailable: 'golApp.GetNamespace' at
MSScriptControl.ScriptControlClass.Run(String ProcedureName, Object[]&
Parameters)
at VocalcomCetelem.frmAgent.AxToolbar1_MailSuccess(Object sender,
_IToolbarEvents_MailSuccessEvent e)
"
It seems that I have this errors when something is wrong with Outlook. I
thought that this happens when Outlook is closed, but after you start it up
it the error stays. Does anybody know why this happens like this?
Thanks a lot in advance!
Pieter
You can find the code here:
'*******VB.NET*************
'declaration of my ScriptControl
Private WithEvents sccMailScript As New MSScriptControl.ScriptControlClass
'initialiszation
sccMailScript.Language = "VBScript"
sccMailScript.AddObject("Toolbar", AxToolbar1, True)
'strText = the *.vbs
sccMailScript.AddCode(strText)
sccMailScript.Run("OnLoad")
'to open the email I run this:
sccMailScript.Run("OnMailSuccess")
'******END VB.NET*************
'******VBS*************
Dim golApp
Dim objInspector
Sub OnLoad
Set golApp = CreateObject("Outlook.Application.8") 'New
Outlook.Application
End Sub
Sub OnWrapupEnd
on error resume next
Application.Navigate ""
if not objInspector is nothing then
objInspector.Close(1)
end if
on error goto 0
End Sub
Sub OnMailSuccess
Dim gnspNameSpace
Dim gmfInbox
Dim gmiItem
Set gnspNameSpace = golApp.GetNamespace("MAPI")
for j=1 to gnspNameSpace.Folders.Count
if instr(1,gnspNameSpace.Folders.Item(j).Name,"Fax")>0 then
set gmfInbox = gnspNameSpace.Folders.Item(j).Folders.Item(4)
For i = 1 To gmfInbox.Items.Count
Set gmiItem = gmfInbox.Items.Item(i)
If gmiItem.EntryID = Toolbar.CallInformation(1).ItemID Then
Set objInspector = gmiItem.GetInspector
objInspector.Display
Exit For
End If
Next
end if
next
End Sub
'*******END VBS**************