Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / June 2006

Tip: Looking for answers? Try searching our database.

VBS error spotting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
akivabrown@gmail.com - 30 Jun 2006 19:41 GMT
    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 = "kevin.xxxxxx@xxxxxx.com"
        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
Sue Mosher [MVP-Outlook] - 30 Jun 2006 20:01 GMT
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 = "kevin.xxxxxx@xxxxxx.com"
   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.
Signature

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
 

> On Error Resume Next
>
[quoted text clipped - 31 lines]
>
> -Kevin Brown
akivabrown@gmail.com - 30 Jun 2006 20:13 GMT
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)

> 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:
>
[quoted text clipped - 51 lines]
> >
> > -Kevin Brown
akivabrown@gmail.com - 30 Jun 2006 20:18 GMT
Got it working. Thanks alot Sue. You are a god. Don't forget that.

> I created the message earlier
>
[quoted text clipped - 58 lines]
> > >
> > > -Kevin Brown
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.