![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |