A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

VBS error spotting



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 30th 06, 08:41 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 9
Default VBS error spotting

On Error Resume Next

'custom for each broker
'Set myItemGS = oFolder.Items.Find("[subject] = ""BH GS 29062006""")
'Set myItemHSBC = oFolder.Items.Find("[subject] = ""BH HSBC
29062006""")
'Set myItemBOA = oFolder.Items.Find("[subject] = ""BH BOA 29062006""")
Set myItemWPac = oFolder.Items.Find("[subject] = ""BH WPac
29062006""")
If Err.Number = 0 then
MsgBox(MyItemWpac & setfiledate)
Else
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
Set objErrMessage = nothing
End If
'Turn back on errors
On Error GoTo 0

For some reason (maybe because i suck at programming) this is not
working, and it seems like it should. What i'm trying to do is catch
the error if the subject os not there and automate an email message to
myself . At first i tried just saying
if myItemWPac = nothing then
'send email to myself'
end if
(there was code to send the email) but i was getting an error that
myItemWPac wasn't initialized. So i went the way i had it pasted on
top. Where it shuts off the errors but then still counts the error
numbers.
If anyone can help i appreciate it greatly.

-Kevin Brown

  #2  
Old June 30th 06, 09:01 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default VBS error spotting

You were on the right track the first time, but you forgot to create the message. Leave in the On Error Resume Next statement, then after you try to return myItemWPac, add:

if myItemWPac = nothing then
'send email to myself
Set objErrMessage = Application.CreateItem(0)
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
end if

I'm assuming you have an Application object somewhere.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

wrote in message ups.com...
On Error Resume Next

'custom for each broker
'Set myItemGS = oFolder.Items.Find("[subject] = ""BH GS 29062006""")
'Set myItemHSBC = oFolder.Items.Find("[subject] = ""BH HSBC
29062006""")
'Set myItemBOA = oFolder.Items.Find("[subject] = ""BH BOA 29062006""")
Set myItemWPac = oFolder.Items.Find("[subject] = ""BH WPac
29062006""")
If Err.Number = 0 then
MsgBox(MyItemWpac & setfiledate)
Else
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
Set objErrMessage = nothing
End If
'Turn back on errors
On Error GoTo 0

For some reason (maybe because i suck at programming) this is not
working, and it seems like it should. What i'm trying to do is catch
the error if the subject os not there and automate an email message to
myself . At first i tried just saying
if myItemWPac = nothing then
'send email to myself'
end if
(there was code to send the email) but i was getting an error that
myItemWPac wasn't initialized. So i went the way i had it pasted on
top. Where it shuts off the errors but then still counts the error
numbers.
If anyone can help i appreciate it greatly.

-Kevin Brown

  #3  
Old June 30th 06, 09:13 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 9
Default VBS error spotting

I created the message earlier

Set myOlApp = createObject("outlook.application")
Set oNameSpace = myOlApp.GetNameSpace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(6)
Set objErrMessage = myOlApp.CreateItem(olMailItem)


Sue Mosher [MVP-Outlook] wrote:

You were on the right track the first time, but you forgot to create the message. Leave in the On Error Resume Next statement, then after you try to return myItemWPac, add:

if myItemWPac = nothing then
'send email to myself
Set objErrMessage = Application.CreateItem(0)
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
end if

I'm assuming you have an Application object somewhere.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

wrote in message ups.com...
On Error Resume Next

'custom for each broker
'Set myItemGS = oFolder.Items.Find("[subject] = ""BH GS 29062006""")
'Set myItemHSBC = oFolder.Items.Find("[subject] = ""BH HSBC
29062006""")
'Set myItemBOA = oFolder.Items.Find("[subject] = ""BH BOA 29062006""")
Set myItemWPac = oFolder.Items.Find("[subject] = ""BH WPac
29062006""")
If Err.Number = 0 then
MsgBox(MyItemWpac & setfiledate)
Else
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
Set objErrMessage = nothing
End If
'Turn back on errors
On Error GoTo 0

For some reason (maybe because i suck at programming) this is not
working, and it seems like it should. What i'm trying to do is catch
the error if the subject os not there and automate an email message to
myself . At first i tried just saying
if myItemWPac = nothing then
'send email to myself'
end if
(there was code to send the email) but i was getting an error that
myItemWPac wasn't initialized. So i went the way i had it pasted on
top. Where it shuts off the errors but then still counts the error
numbers.
If anyone can help i appreciate it greatly.

-Kevin Brown


  #4  
Old June 30th 06, 09:18 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 9
Default VBS error spotting

Got it working. Thanks alot Sue. You are a god. Don't forget that.



wrote:

I created the message earlier

Set myOlApp = createObject("outlook.application")
Set oNameSpace = myOlApp.GetNameSpace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(6)
Set objErrMessage = myOlApp.CreateItem(olMailItem)


Sue Mosher [MVP-Outlook] wrote:

You were on the right track the first time, but you forgot to create the message. Leave in the On Error Resume Next statement, then after you try to return myItemWPac, add:

if myItemWPac = nothing then
'send email to myself
Set objErrMessage = Application.CreateItem(0)
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
end if

I'm assuming you have an Application object somewhere.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

wrote in message ups.com...
On Error Resume Next

'custom for each broker
'Set myItemGS = oFolder.Items.Find("[subject] = ""BH GS 29062006""")
'Set myItemHSBC = oFolder.Items.Find("[subject] = ""BH HSBC
29062006""")
'Set myItemBOA = oFolder.Items.Find("[subject] = ""BH BOA 29062006""")
Set myItemWPac = oFolder.Items.Find("[subject] = ""BH WPac
29062006""")
If Err.Number = 0 then
MsgBox(MyItemWpac & setfiledate)
Else
objErrMessage.To = "
objErrMessage.Subject = "No item received from WPac"
objErrMessage.Body = "File not received. Checked at "
objErrMessage.Send
Set objErrMessage = nothing
End If
'Turn back on errors
On Error GoTo 0

For some reason (maybe because i suck at programming) this is not
working, and it seems like it should. What i'm trying to do is catch
the error if the subject os not there and automate an email message to
myself . At first i tried just saying
if myItemWPac = nothing then
'send email to myself'
end if
(there was code to send the email) but i was getting an error that
myItemWPac wasn't initialized. So i went the way i had it pasted on
top. Where it shuts off the errors but then still counts the error
numbers.
If anyone can help i appreciate it greatly.

-Kevin Brown


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add-in doesnt load when outlook is started from VBS Msyrak Add-ins for Outlook 1 May 26th 06 04:51 PM
Add ContactItems to DLItem with VBS Christoph Fricke Outlook and VBA 8 May 10th 06 07:03 PM
Displaying attached picture on a form with VBS ? philippe Outlook and VBA 1 April 26th 06 05:37 PM
Outlook automation using vbs Marceepoo Outlook - Installation 1 January 17th 06 05:18 AM
Pls comment my VBS Tony WONG Outlook and VBA 1 January 10th 06 04:34 PM


All times are GMT +1. The time now is 07:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.