Checking if folder/path exists: Outlook Form 
Author Message
 Checking if folder/path exists: Outlook Form

Hi there. I'm trying to figure out a quick and dirty Visual Basic script
in a form I am working on, and I'm pretty much at the end of my rope
here. I need the script to check and see if certain paths/folders exist
on a file system (and not in the Outlook folders), and then be able to
do error handling. I have tried several different methods with "On
Error" and "If ERR.Number...", but they have failed. Basically, here is
the code:

Function Item_Open()
Item.Body = "blah blah blah"
End Function
Function Item_Send()
   Item.Attachments.Add "C:\WINDOWS\DESKTOP\FOO.BAR"
   Item.SaveAs "\\ip70\Tech Support\client correspondence\" & Item.To &
"\" & Item.Subject & ".msg"
End Function

The problems happen twofold... First, I want to be able to error out on
the adding of the attachment, having the item not be sent if the
attachment doesn't exist, and giving the user a chance to create the
attachment, and then resend the file. The second problem occurs when the
item is saved... The Item.To is the name of the client AND the directory
(which might not be the same), so I would like a MsgBox to appear
reminding the person to do this manually, but have the email go through
in this case. *sigh*

The error numbers are easy--probably 53 or 76, but when I create the
right conditions, and try to have the program tell me by putting a
"MsgBox ERR.Number" in after the Item.SaveAs line, I just get a
"internal application error", and the email gets sent, but the message
box doesn't appear.

The attachments line used to be within the Item_Open routine, but I
found that my saved form *itself* was getting overloaded with duplicate
attachments, and wasn't updating when a new one was created. Even using
a:

While Attachments.Count > 0
        Attachments.Remove 1
Wend

in Item_Open did nothing. The attachments seemed to disappear, but when
the file was received, the user had three of the same files (which was
bad, since the file is over a Meg in size). I even tried taking out the
"Attachments.Add" line, and only have the Attachments.Remove stuff in
the form, but the invisible attachments still wouldn't disappear!

Any help would be much appreciated. Thanks.

Rory

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Tue, 18 Jun 2002 03:00:00 GMT  
 Checking if folder/path exists: Outlook Form
You probably ought to take a look at the Scripting Runtime model, which
gives you a FileSystemObject object to work with to do whatever yoiu need
within the file system. Follow the link from
http://www.slipstick.com/dev/VBScript.htm.

For error trapping within VBScript, use an On Error Resume Next statement,
then check for Err <> 0 as appropriate (in other words, when you think an
error is likely to have occurred).
--
Sue Mosher
Author of
  "Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
  "Microsoft Outlook 2000 E-mail and Fax Guide" (12/99)

Outlook and Exchange solutions at http://www.slipstick.com

Quote:

> Hi there. I'm trying to figure out a quick and dirty visual basic script
> in a form I am working on, and I'm pretty much at the end of my rope
> here. I need the script to check and see if certain paths/folders exist
> on a file system (and not in the Outlook folders), and then be able to
> do error handling. I have tried several different methods with "On
> Error" and "If ERR.Number...", but they have failed. Basically, here is
> the code:

> Function Item_Open()
> Item.Body = "blah blah blah"
> End Function
> Function Item_Send()
>    Item.Attachments.Add "C:\WINDOWS\DESKTOP\FOO.BAR"
>    Item.SaveAs "\\ip70\Tech Support\client correspondence\" & Item.To &
> "\" & Item.Subject & ".msg"
> End Function

> The problems happen twofold... First, I want to be able to error out on
> the adding of the attachment, having the item not be sent if the
> attachment doesn't exist, and giving the user a chance to create the
> attachment, and then resend the file. The second problem occurs when the
> item is saved... The Item.To is the name of the client AND the directory
> (which might not be the same), so I would like a MsgBox to appear
> reminding the person to do this manually, but have the email go through
> in this case. *sigh*

> The error numbers are easy--probably 53 or 76, but when I create the
> right conditions, and try to have the program tell me by putting a
> "MsgBox ERR.Number" in after the Item.SaveAs line, I just get a
> "internal application error", and the email gets sent, but the message
> box doesn't appear.

> The attachments line used to be within the Item_Open routine, but I
> found that my saved form *itself* was getting overloaded with duplicate
> attachments, and wasn't updating when a new one was created. Even using
> a:

> While Attachments.Count > 0
> Attachments.Remove 1
> Wend

> in Item_Open did nothing. The attachments seemed to disappear, but when
> the file was received, the user had three of the same files (which was
> bad, since the file is over a Meg in size). I even tried taking out the
> "Attachments.Add" line, and only have the Attachments.Remove stuff in
> the form, but the invisible attachments still wouldn't disappear!

> Any help would be much appreciated. Thanks.

> Rory

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 19 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Check if path exists

2. How to check if a path exists

3. Check if UNC path exists

4. Check if folder exists

5. Check if folder exists

6. Check if folder exists and create if not

7. Checking if a FOLDER or DIRECTORY exists.

8. Newbie Question: How to check to see if a folder exists

9. Check if a folder exist and copy files...

10. Check if folder exists

11. Checking for existing folders

12. How do I check if a folder exists?

 

 
Powered by phpBB® Forum Software