![]() |
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
|
|||
|
|||
![]()
Hi,
I have a script which replaces rules in OL2003. The way I have folders defined is like this: Dim xxx As MAPIFolder Set my_xxx = Inbox.Folders.Item("xxx") ' ... then after much logic to determine if this is the correct email .... objItem.Move my_xxx Is there any way to: 1) Create a folder if it doesn't exit 2) Avoid the Dim/Set steps? TIA -T |
Ads |
#2
|
|||
|
|||
![]()
1) Create a folder if it doesn't exit
On Error Resume Next Set myFolder = Inbox.Folders("My Folder") If myFolder Is Nothing Then Set myFolder = Inbox.Folders.Add("My Folder") End If 2) Avoid the Dim/Set steps? Why would you want to avoid good programming practice? -- 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 "gamename" wrote in message ups.com... Hi, I have a script which replaces rules in OL2003. The way I have folders defined is like this: Dim xxx As MAPIFolder Set my_xxx = Inbox.Folders.Item("xxx") ' ... then after much logic to determine if this is the correct email ... objItem.Move my_xxx Is there any way to: 1) Create a folder if it doesn't exit 2) Avoid the Dim/Set steps? TIA -T |
#3
|
|||
|
|||
![]()
Sue Mosher [MVP-Outlook] wrote:
1) Create a folder if it doesn't exit On Error Resume Next Set myFolder = Inbox.Folders("My Folder") If myFolder Is Nothing Then Set myFolder = Inbox.Folders.Add("My Folder") End If 2) Avoid the Dim/Set steps? Why would you want to avoid good programming practice? So, every single possible folder needs to be pre-defined in VB? -- 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 "gamename" wrote in message ups.com... Hi, I have a script which replaces rules in OL2003. The way I have folders defined is like this: Dim xxx As MAPIFolder Set my_xxx = Inbox.Folders.Item("xxx") ' ... then after much logic to determine if this is the correct email ... objItem.Move my_xxx Is there any way to: 1) Create a folder if it doesn't exit 2) Avoid the Dim/Set steps? TIA -T |
#4
|
|||
|
|||
![]()
No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.
-- 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 "gamename" wrote in message oups.com... Sue Mosher [MVP-Outlook] wrote: 1) Create a folder if it doesn't exit On Error Resume Next Set myFolder = Inbox.Folders("My Folder") If myFolder Is Nothing Then Set myFolder = Inbox.Folders.Add("My Folder") End If 2) Avoid the Dim/Set steps? Why would you want to avoid good programming practice? So, every single possible folder needs to be pre-defined in VB? "gamename" wrote in message ups.com... Hi, I have a script which replaces rules in OL2003. The way I have folders defined is like this: Dim xxx As MAPIFolder Set my_xxx = Inbox.Folders.Item("xxx") ' ... then after much logic to determine if this is the correct email ... objItem.Move my_xxx Is there any way to: 1) Create a folder if it doesn't exit 2) Avoid the Dim/Set steps? TIA -T |
#5
|
|||
|
|||
![]() Sue Mosher [MVP-Outlook] wrote: No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder. OK. Is there an example somewhere for reference? Thanks, -T |
#6
|
|||
|
|||
![]()
You already had it in your earlier code snippet that you posted.
-- 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 "gamename" wrote in message oups.com... Sue Mosher [MVP-Outlook] wrote: No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder. OK. Is there an example somewhere for reference? Thanks, -T |
#7
|
|||
|
|||
![]()
So, you're saying the way I had it defined in the original question is
correct? -T Sue Mosher [MVP-Outlook] wrote: You already had it in your earlier code snippet that you posted. -- 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 "gamename" wrote in message oups.com... Sue Mosher [MVP-Outlook] wrote: No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder. OK. Is there an example somewhere for reference? Thanks, -T |
#8
|
|||
|
|||
![]()
Dim xxx As MAPIFolder
Set xxx = some expression to get the folder ' move items to xxx Set xxx = some expression to get another folder ' move items to xxx -- 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 "gamename" wrote in message ups.com... So, you're saying the way I had it defined in the original question is correct? -T Sue Mosher [MVP-Outlook] wrote: You already had it in your earlier code snippet that you posted. -- 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 "gamename" wrote in message oups.com... Sue Mosher [MVP-Outlook] wrote: No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder. OK. Is there an example somewhere for reference? Thanks, -T |
#9
|
|||
|
|||
![]() Ah, ok. Now I see what you're saying. Thanks, -T Sue Mosher [MVP-Outlook] wrote: Dim xxx As MAPIFolder Set xxx = some expression to get the folder ' move items to xxx Set xxx = some expression to get another folder ' move items to xxx -- 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 "gamename" wrote in message ups.com... So, you're saying the way I had it defined in the original question is correct? -T Sue Mosher [MVP-Outlook] wrote: You already had it in your earlier code snippet that you posted. -- 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 "gamename" wrote in message oups.com... Sue Mosher [MVP-Outlook] wrote: No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder. OK. Is there an example somewhere for reference? Thanks, -T |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Move Personal Folders Up or Down | Doug Recla | Outlook - General Queries | 2 | May 27th 06 03:45 PM |
move inbox & merge archive folders? | ny_dancer | Outlook - General Queries | 1 | April 22nd 06 12:37 AM |
How to move folders to another drive | Fred | Outlook Express | 6 | April 19th 06 09:42 PM |
Backup OE folders to move to new hard drive | Walter Cohen | Outlook Express | 2 | April 8th 06 03:59 PM |
Cannot Move IMAP Emails From Inbox To Folders Anymore | JC | Outlook Express | 1 | March 31st 06 08:41 PM |