how can i know the complete path to an outlook folder ?

A

An Dong

hello,
i want to make my forms (based on the task form) "understand" where
they have to save. i found a function but it doesn't work. i don't
know if it's because my outlook is french... how can i know the full
path to the target folder where i want to save items using this form ?
here is the code i found. the only thing to do, it seems, is to enter
the full path to the target folder.
Thank you
AnDong

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Personal Folders/Journal/test"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub


Function Item_Open()
If Item.Size = 0 Then
' for appointments and journal items, set Start
' according to option in InitOpts
If mblnResetStart Then
If Item.Class = olAppointment Or _
Item.Class = olJournal Then
Item.Start = Now
End If
End If
If Item.BillingInformation <> "IsCopy" Then
mblnSaveInTarget = True
Call InitOpts
End If
End If
End Function


Function Item_Write()
Dim objCopy
Dim objTargetFolder
If mblnSaveInTarget And Not Item.Saved Then
Set objTargetFolder = GetMAPIFolder(mstrTargetFolder)
If Not objTargetFolder Is Nothing Then
Item.BillingInformation = "IsCopy"
Set objCopy = Item.Copy
objCopy.Move objTargetFolder
Item_Write = False
Item.Close olDiscard
End If
End If

Set objCopy = Nothing
Set objTargetFolder = Nothing
End Function


Function GetMAPIFolder(strName)
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim I
Dim blnFound

Set objNS = Application.GetNamespace("MAPI")

arrName = Split(strName, "/")
Set objFolders = objNS.Folders
blnFound = False
For I = 0 To UBound(arrName)
For Each objFolder In objFolders
If objFolder.Name = arrName(I) Then
Set objFolders = objFolder.Folders
blnFound = True
Exit For
Else
blnFound = False
End If
Next
If blnFound = False Then
Exit For
End If
Next
If blnFound = True Then
Set GetMAPIFolder = objFolder
End If

Set objNS = Nothing
Set objFolder = Nothing
Set objFolders = Nothing
End Function
 
S

Sue Mosher [MVP-Outlook]

Look at your Outlook folder list to determine the path -- starting from the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also examine the
FolderPath property for the folder or, without Outlook Spy, write a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run code.
 
A

An Dong

Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please ?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to Item.To
! Why ?
Thank you for your help.
AnDong
 
S

Sue Mosher [MVP-Outlook]

The name of the top-level folder in your mailbox is:

Boîte aux lettres - HUBERT Antoine

What is the name of the folder underneath the mailbox that you want to use?

If you are using Outlook 2002 or 2003, you can use FolderPath in VBA to
return the name of the current folder:

strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from <All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to see its
Help topic. You'll see that the TaskItem object has no To property. What
were you trying to use To to accomplish?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please ?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to Item.To
! Why ?
Thank you for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
Look at your Outlook folder list to determine the path -- starting from the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also examine the
FolderPath property for the folder or, without Outlook Spy, write a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run code.
 
A

An Dong

Hello,
1) the name of the folder underneath is test. i can't use your code
(strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath)
because i am under outlook 2000
i tried :
mstrTargetFolder = "/Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "\Boîte aux lettres - HUBERT Antoine\test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine\test"
nothing works.
The complete code is from journalmove.oft, the sample i found on the
page you indicated :
http://www.outlookcode.com/d/forms/saveinfolder.htm. it is designed
for journal items, but they say "You can also adapt the technique to
other types of forms, simply by copying the source code from the
sample and modifying the target folder path, as described under
Setup." i'm starting to doubt.

2) I droped a To field in order to choose the reciever of an
automatically sent mail : the user chooses the reciever in the To
field in the form, then click a button and the mail is sent (or should
be). now I choose se reciever, I click and nothing happens. bad.

3) I want to set the StartDate of my custom task form to now. Why
doesn't this code work ?
Function Item_Open()
Item.Start = Now
End Function

Thank you very much for your help.
AnDong

Sue Mosher said:
The name of the top-level folder in your mailbox is:

Boîte aux lettres - HUBERT Antoine

What is the name of the folder underneath the mailbox that you want to use?

If you are using Outlook 2002 or 2003, you can use FolderPath in VBA to
return the name of the current folder:

strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from <All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to see its
Help topic. You'll see that the TaskItem object has no To property. What
were you trying to use To to accomplish?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please ?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to Item.To
! Why ?
Thank you for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
Look at your Outlook folder list to determine the path -- starting from the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also examine the
FolderPath property for the folder or, without Outlook Spy, write a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run code.

hello,
i want to make my forms (based on the task form) "understand" where
they have to save. i found a function but it doesn't work. i don't
know if it's because my outlook is french... how can i know the full
path to the target folder where i want to save items using this form ?
here is the code i found. the only thing to do, it seems, is to enter
the full path to the target folder.
Thank you
AnDong

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Personal Folders/Journal/test"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub
 
S

Sue Mosher [MVP-Outlook]

1) What happens when you step through the code? Does it ever find the
mailbox root?

You could also locate the test folder by getting the Inbox with
Namespace.GetDefaultFolder, then going up to the mailbox root with Parent
and down again:

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objRoot = objInbox.Parent
Set objTest = objRoot.Folders("test")

2) This is a regular mail message that you want to send, not a task request,
right? If you want to send a message to the person in the To box, you'll
need to include code behind your form to create the mail message and then
loop through the Recipients collection to get each address and add it to the
message.

3) Because there is no TaskItem.Start property. It's StartDate. When in
doubt, check the object browser: Press ALt+F11 to open the VBA environment
in Outlook, then press F2. Switch from <All Libraries> to Outlook to browse
all Outlook objects and their properties, methods, and events.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) the name of the folder underneath is test. i can't use your code
(strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath)
because i am under outlook 2000
i tried :
mstrTargetFolder = "/Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "\Boîte aux lettres - HUBERT Antoine\test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine\test"
nothing works.
The complete code is from journalmove.oft, the sample i found on the
page you indicated :
http://www.outlookcode.com/d/forms/saveinfolder.htm. it is designed
for journal items, but they say "You can also adapt the technique to
other types of forms, simply by copying the source code from the
sample and modifying the target folder path, as described under
Setup." i'm starting to doubt.

2) I droped a To field in order to choose the reciever of an
automatically sent mail : the user chooses the reciever in the To
field in the form, then click a button and the mail is sent (or should
be). now I choose se reciever, I click and nothing happens. bad.

3) I want to set the StartDate of my custom task form to now. Why
doesn't this code work ?
Function Item_Open()
Item.Start = Now
End Function

Thank you very much for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
The name of the top-level folder in your mailbox is:

Boîte aux lettres - HUBERT Antoine

What is the name of the folder underneath the mailbox that you want to use?

If you are using Outlook 2002 or 2003, you can use FolderPath in VBA to
return the name of the current folder:

strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from <All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to see its
Help topic. You'll see that the TaskItem object has no To property. What
were you trying to use To to accomplish?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please ?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to Item.To
! Why ?
Thank you for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
Look at your Outlook folder list to determine the path -- starting
from
the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also
examine
the
FolderPath property for the folder or, without Outlook Spy, write a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run code.
hello,
i want to make my forms (based on the task form) "understand" where
they have to save. i found a function but it doesn't work. i don't
know if it's because my outlook is french... how can i know the full
path to the target folder where i want to save items using this form ?
here is the code i found. the only thing to do, it seems, is to enter
the full path to the target folder.
Thank you
AnDong

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Personal Folders/Journal/test"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub
 
A

An Dong

Hello,
1) Thank you for your code, but how can I use it? in a macro? i'm
sorry i really am a newbie

2) Yes, it is a regular mail message, IPM.Mail. I included the
following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To 'Item.To refers to the To field i droped into my
custom
'task form (which i choose in the all message fields list)
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Send
End Sub
I don't understant why i doesn't work and i don't understand what you
mean by "loop through the Recipients collection to get each address
and add it to the message."

3) I have an other problem with my adress fields. Trying to customize
a mail form, i noticed that the tiniest piece of code forbids to
display the message in the "volet de visualisation" (in outlook, the
frame that allows to read messages without having to open them in a
new window). So that i decided to create my form and then to write a
function to create a new IPM.Mail, fill it with the datas of my custom
form, close my custom form.
But instructions like Item.whateverfield = Item.To,
field-in-the-new-item = Item.To and other Item.whateverfield =
Item.whatever-adress-field open a msgbox to ask the user whether it's
ok if the forms has acces to the contact list. I tried to link a field
(left click, properties) to my To field and then to read the content
ot that field, but it becomes a control and i can't access the value.
So I need to do one of these things :
- allow a custom form with code to be displayed in the "volet de
visualisation"
- allow my form to access the contact list
- read the data of controls.

Thank you very much
AnDong


Sue Mosher said:
1) What happens when you step through the code? Does it ever find the
mailbox root?

You could also locate the test folder by getting the Inbox with
Namespace.GetDefaultFolder, then going up to the mailbox root with Parent
and down again:

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objRoot = objInbox.Parent
Set objTest = objRoot.Folders("test")

2) This is a regular mail message that you want to send, not a task request,
right? If you want to send a message to the person in the To box, you'll
need to include code behind your form to create the mail message and then
loop through the Recipients collection to get each address and add it to the
message.

3) Because there is no TaskItem.Start property. It's StartDate. When in
doubt, check the object browser: Press ALt+F11 to open the VBA environment
in Outlook, then press F2. Switch from <All Libraries> to Outlook to browse
all Outlook objects and their properties, methods, and events.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) the name of the folder underneath is test. i can't use your code
(strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath)
because i am under outlook 2000
i tried :
mstrTargetFolder = "/Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "\Boîte aux lettres - HUBERT Antoine\test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine\test"
nothing works.
The complete code is from journalmove.oft, the sample i found on the
page you indicated :
http://www.outlookcode.com/d/forms/saveinfolder.htm. it is designed
for journal items, but they say "You can also adapt the technique to
other types of forms, simply by copying the source code from the
sample and modifying the target folder path, as described under
Setup." i'm starting to doubt.

2) I droped a To field in order to choose the reciever of an
automatically sent mail : the user chooses the reciever in the To
field in the form, then click a button and the mail is sent (or should
be). now I choose se reciever, I click and nothing happens. bad.

3) I want to set the StartDate of my custom task form to now. Why
doesn't this code work ?
Function Item_Open()
Item.Start = Now
End Function

Thank you very much for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
The name of the top-level folder in your mailbox is:

Boîte aux lettres - HUBERT Antoine

What is the name of the folder underneath the mailbox that you want to use?

If you are using Outlook 2002 or 2003, you can use FolderPath in VBA to
return the name of the current folder:

strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from <All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to see its
Help topic. You'll see that the TaskItem object has no To property. What
were you trying to use To to accomplish?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please ?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to Item.To
! Why ?
Thank you for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
Look at your Outlook folder list to determine the path -- starting
from
the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also
examine
the
FolderPath property for the folder or, without Outlook Spy, write a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run code.

hello,
i want to make my forms (based on the task form) "understand" where
they have to save. i found a function but it doesn't work. i don't
know if it's because my outlook is french... how can i know the full
path to the target folder where i want to save items using this form ?
here is the code i found. the only thing to do, it seems, is to enter
the full path to the target folder.
Thank you
AnDong

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Personal Folders/Journal/test"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub
 
S

Sue Mosher [MVP-Outlook]

1) If you're running code behind a form, that's where you put the code -- in
the form's script window.

2) Loop through the Recipients collection means to iterate it:

For Each objRecep in Item.Recipients
strTo = strTo & ";" & objRecip.Address
Next
NewMail.To = Mid(strTo, 1)

3) See http://www.outlookcode.com/d/sec.htm for your options with regard to
the "object model guard" security in Outlook 2000 SP2 and later versions.
Redemption is highly recommended.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) Thank you for your code, but how can I use it? in a macro? i'm
sorry i really am a newbie

2) Yes, it is a regular mail message, IPM.Mail. I included the
following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To 'Item.To refers to the To field i droped into my
custom
'task form (which i choose in the all message fields list)
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Send
End Sub
I don't understant why i doesn't work and i don't understand what you
mean by "loop through the Recipients collection to get each address
and add it to the message."

3) I have an other problem with my adress fields. Trying to customize
a mail form, i noticed that the tiniest piece of code forbids to
display the message in the "volet de visualisation" (in outlook, the
frame that allows to read messages without having to open them in a
new window). So that i decided to create my form and then to write a
function to create a new IPM.Mail, fill it with the datas of my custom
form, close my custom form.
But instructions like Item.whateverfield = Item.To,
field-in-the-new-item = Item.To and other Item.whateverfield =
Item.whatever-adress-field open a msgbox to ask the user whether it's
ok if the forms has acces to the contact list. I tried to link a field
(left click, properties) to my To field and then to read the content
ot that field, but it becomes a control and i can't access the value.
So I need to do one of these things :
- allow a custom form with code to be displayed in the "volet de
visualisation"
- allow my form to access the contact list
- read the data of controls.

Thank you very much
AnDong


Sue Mosher said:
1) What happens when you step through the code? Does it ever find the
mailbox root?

You could also locate the test folder by getting the Inbox with
Namespace.GetDefaultFolder, then going up to the mailbox root with Parent
and down again:

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objRoot = objInbox.Parent
Set objTest = objRoot.Folders("test")

2) This is a regular mail message that you want to send, not a task
request,
right? If you want to send a message to the person in the To box, you'll
need to include code behind your form to create the mail message and then
loop through the Recipients collection to get each address and add it to
the
message.

3) Because there is no TaskItem.Start property. It's StartDate. When in
doubt, check the object browser: Press ALt+F11 to open the VBA
environment
in Outlook, then press F2. Switch from <All Libraries> to Outlook to
browse
all Outlook objects and their properties, methods, and events.


An Dong said:
Hello,
1) the name of the folder underneath is test. i can't use your code
(strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath)
because i am under outlook 2000
i tried :
mstrTargetFolder = "/Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "\Boîte aux lettres - HUBERT Antoine\test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine\test"
nothing works.
The complete code is from journalmove.oft, the sample i found on the
page you indicated :
http://www.outlookcode.com/d/forms/saveinfolder.htm. it is designed
for journal items, but they say "You can also adapt the technique to
other types of forms, simply by copying the source code from the
sample and modifying the target folder path, as described under
Setup." i'm starting to doubt.

2) I droped a To field in order to choose the reciever of an
automatically sent mail : the user chooses the reciever in the To
field in the form, then click a button and the mail is sent (or should
be). now I choose se reciever, I click and nothing happens. bad.

3) I want to set the StartDate of my custom task form to now. Why
doesn't this code work ?
Function Item_Open()
Item.Start = Now
End Function

Thank you very much for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
The name of the top-level folder in your mailbox is:

Boîte aux lettres - HUBERT Antoine

What is the name of the folder underneath the mailbox that you want
to use?

If you are using Outlook 2002 or 2003, you can use FolderPath in VBA
to
return the name of the current folder:

strFolderName =
Application.ActiveExplorer.CurrentFolder.FolderPath

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from
<All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to
see its
Help topic. You'll see that the TaskItem object has no To property.
What
were you trying to use To to accomplish?

Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte
aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please
?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a
message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to
Item.To
! Why ?
Thank you for your help.
AnDong

message
Look at your Outlook folder list to determine the path --
starting from
the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also examine
the
FolderPath property for the folder or, without Outlook Spy, write
a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run
code.
hello,
i want to make my forms (based on the task form) "understand" where
they have to save. i found a function but it doesn't work. i
don't
know if it's because my outlook is french... how can i know the full
path to the target folder where i want to save items using this form ?
here is the code i found. the only thing to do, it seems, is to enter
the full path to the target folder.
Thank you
AnDong

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Personal Folders/Journal/test"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub
 
A

An Dong

Hello,
Thank you very much for all you did. Now It think everything is ok. I
had never programmed in vb before, and now I feel releaved !
Thank you again
AnDong
PS : redemption works great !

Sue Mosher said:
1) If you're running code behind a form, that's where you put the code -- in
the form's script window.

2) Loop through the Recipients collection means to iterate it:

For Each objRecep in Item.Recipients
strTo = strTo & ";" & objRecip.Address
Next
NewMail.To = Mid(strTo, 1)

3) See http://www.outlookcode.com/d/sec.htm for your options with regard to
the "object model guard" security in Outlook 2000 SP2 and later versions.
Redemption is highly recommended.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



An Dong said:
Hello,
1) Thank you for your code, but how can I use it? in a macro? i'm
sorry i really am a newbie

2) Yes, it is a regular mail message, IPM.Mail. I included the
following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To 'Item.To refers to the To field i droped into my
custom
'task form (which i choose in the all message fields list)
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Send
End Sub
I don't understant why i doesn't work and i don't understand what you
mean by "loop through the Recipients collection to get each address
and add it to the message."

3) I have an other problem with my adress fields. Trying to customize
a mail form, i noticed that the tiniest piece of code forbids to
display the message in the "volet de visualisation" (in outlook, the
frame that allows to read messages without having to open them in a
new window). So that i decided to create my form and then to write a
function to create a new IPM.Mail, fill it with the datas of my custom
form, close my custom form.
But instructions like Item.whateverfield = Item.To,
field-in-the-new-item = Item.To and other Item.whateverfield =
Item.whatever-adress-field open a msgbox to ask the user whether it's
ok if the forms has acces to the contact list. I tried to link a field
(left click, properties) to my To field and then to read the content
ot that field, but it becomes a control and i can't access the value.
So I need to do one of these things :
- allow a custom form with code to be displayed in the "volet de
visualisation"
- allow my form to access the contact list
- read the data of controls.

Thank you very much
AnDong


Sue Mosher said:
1) What happens when you step through the code? Does it ever find the
mailbox root?

You could also locate the test folder by getting the Inbox with
Namespace.GetDefaultFolder, then going up to the mailbox root with Parent
and down again:

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objRoot = objInbox.Parent
Set objTest = objRoot.Folders("test")

2) This is a regular mail message that you want to send, not a task
request,
right? If you want to send a message to the person in the To box, you'll
need to include code behind your form to create the mail message and then
loop through the Recipients collection to get each address and add it to
the
message.

3) Because there is no TaskItem.Start property. It's StartDate. When in
doubt, check the object browser: Press ALt+F11 to open the VBA
environment
in Outlook, then press F2. Switch from <All Libraries> to Outlook to
browse
all Outlook objects and their properties, methods, and events.


Hello,
1) the name of the folder underneath is test. i can't use your code
(strFolderName = Application.ActiveExplorer.CurrentFolder.FolderPath)
because i am under outlook 2000
i tried :
mstrTargetFolder = "/Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine/test"
mstrTargetFolder = "\Boîte aux lettres - HUBERT Antoine\test"
mstrTargetFolder = "Boîte aux lettres - HUBERT Antoine\test"
nothing works.
The complete code is from journalmove.oft, the sample i found on the
page you indicated :
http://www.outlookcode.com/d/forms/saveinfolder.htm. it is designed
for journal items, but they say "You can also adapt the technique to
other types of forms, simply by copying the source code from the
sample and modifying the target folder path, as described under
Setup." i'm starting to doubt.

2) I droped a To field in order to choose the reciever of an
automatically sent mail : the user chooses the reciever in the To
field in the form, then click a button and the mail is sent (or should
be). now I choose se reciever, I click and nothing happens. bad.

3) I want to set the StartDate of my custom task form to now. Why
doesn't this code work ?
Function Item_Open()
Item.Start = Now
End Function

Thank you very much for your help.
AnDong

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
The name of the top-level folder in your mailbox is:

Boîte aux lettres - HUBERT Antoine

What is the name of the folder underneath the mailbox that you want
to use?

If you are using Outlook 2002 or 2003, you can use FolderPath in VBA
to
return the name of the current folder:

strFolderName =
Application.ActiveExplorer.CurrentFolder.FolderPath

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from
<All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to
see its
Help topic. You'll see that the TaskItem object has no To property.
What
were you trying to use To to accomplish?

Hello,
1) Of course i tried to determine the path like for a folder on my
hard drive, but it doesn't work.
My session name is a bit complicated (Outlook Aujourd'hui - [Boîte
aux
lettres - HUBERT Antoine]) and i don't know what the name of the
folder is (i think it is CetteSessionOutlook but i'm not sure) so i
tried with an other "root" folder : Account Tracking/test (and as i
was not sure i also tried Account Tracking\test), i doesn't work
either.
I'd like to use your code,
Application.ActiveExplorer.CurrentFolder.FolderPath, but how please
?
Do i have to write a macro in VBA, something in an item in VBS ???
2) i have an other problem : when i create a form based on a
message
form, i can use the following code :
Sub transfert_Click()
Set NewItem = Application.CreateItem(0)
NewItem.To = Item.To
NewItem.Subject = "Un nouveau bordereau de suivi vient de vous être
adressé."
NewItem.Body = ""
NewItem.Send
End Sub
But when i drop a "To" field in a task form, i can't refer to
Item.To
! Why ?
Thank you for your help.
AnDong

message
Look at your Outlook folder list to determine the path --
starting
from
the
top folder in a particular store and working your way down the hierarchy,
just as you would figure out the path of a folder on your hard drive.

If you have OUtlook Spy and Outlook 2002 or 2003, you can also
examine
the
FolderPath property for the folder or, without Outlook Spy, write
a little
VBA code to return it from the currently displayed folder
(Application.ActiveExplorer.CurrentFolder.FolderPath).

Don't forget that your form must be published in order to run
code.

hello,
i want to make my forms (based on the task form) "understand" where
they have to save. i found a function but it doesn't work. i
don't
know if it's because my outlook is french... how can i know the full
path to the target folder where i want to save items using this form ?
here is the code i found. the only thing to do, it seems, is to enter
the full path to the target folder.
Thank you
AnDong

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Personal Folders/Journal/test"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top